danhper / eclair

A Solidity interpreter
https://eclair.so
MIT License
55 stars 1 forks source link

Add a way to specify the block number for calls #12

Closed beeb closed 4 months ago

beeb commented 4 months ago

I would love to be able to specify a block number to retrieve historical data from a contract.

Not sure how the syntax would look, maybe something like myContract.myFunction{ block: 1234 }(arg1).

Alternatively a repl.setBlockNumber(1234) which would then set a context for all future calls, with maybe an overload repl.setBlockNumber("latest") or repl.unsetBlockNumber() which would then reset to using the latest block.

danhper commented 4 months ago

Hi @beeb , That would definitely be very useful! I feel like most of the time it makes more sense to make several calls on the same block rather than just one, so I prefer the second option, although both could also coexist. I'll add this very soon!

danhper commented 4 months ago

@beeb This is now possible, using both the call options syntax and the repl.block function

beeb commented 4 months ago

Very cool, thanks a lot for the quick reaction!