AxiomREPL Examples
Some additional examples of things that people have done with AxiomREPL to help kickstart your creativity.
Average Account Balance
let total = constant(0);
const periods = 25;
for (let i = 0; i < periods; i++) {
const targetBlock = sub(endBlock, mul(constant(i), blockInterval));
const bal = getAccount(targetBlock, user).balance().toCircuitValue();
total = add(total, bal);
}
const avg = div(total, constant(periods));
addToCallback(avg);{
"user": "0xe76a90E3069c9d86e666DcC687e76fcecf4429cF",
"endBlock": 9900000,
"blockInterval": 1000
}Last updated