0

I know the ethereum address of a deployed smart contract. I know the source code of this contract but I am not the owner.

Is there a way, with foundry tools to read this smart contract's variables ?

I also want to know if it is possible to interact with this smart contrat from foundry tools command line (call a method, ...)

Thanks

1 Answer 1

1

You can use the cast call command line utility to read on-chain data. It's part of the foundry suite.

cast call --help

You'll need to know the signature of the function you want to call. Eg : To check the totalSupply() of a token :

cast call 0xc2132D05D31c914a87C6611C10748AEb04B58e8F "totalSupply()(uint256)" --rpc-url https://polygon.llamarpc.com 

To check balanceOf(address) :

cast call 0xc2132D05D31c914a87C6611C10748AEb04B58e8F "balanceOf(address)(uint256)" 0x53AB61eE41FA202227Eb4e7B176208FC626DC8A9 --rpc-url https://polygon.llamarpc.com 
2
  • What is 0x53AB61eE41FA202227Eb4e7B176208FC626DC8A9 ?
    – Bob5421
    Dec 21, 2023 at 16:40
  • It's just a wallet address. I'm checking what is the Polygon USDT balance for that wallet. Dec 23, 2023 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.