I am trying to find out if there is a way to call functions from a smart contract which is already deployed on mainnet/testnet, without using web3. If so, how to do that?
3 Answers
You might get more specific, on-point ideas if you describe what you DO want to do.
web3 is merely an abstraction of lower-level methods, so yes, such methods exist. Other abstractions exist as well:
- other JS libraries
- libraries in other languages
- JSON RPC which is accessible via curl and tools like Postman
- Etherscan and MyEtherWallet provide a UI
- Mist can talk to contract functions
- You can build your own node to interpret the blockchain and construct an API according to taste
Hope it helps.
- 55,151
- 11
- 89
- 145
You may use curl to send the request ... an example can be found in this question: "Exceeds block gas limit" error when i try to send transaction via personal_sendTransaction You will need to properly format the function parameters and it's signature, but that depends on the function you want to call.
- 679
- 4
- 8
You can call the functions on a deployed smart contract from some websites - for example, using the following steps:
- visit
www.myetherwallet.com - connect the wallet you wish to send the transaction from - the quickest of these is probably MetaMask, but you can easily connect a hardware wallet. You'll need a bit of ETH to pay the gas cost of the function calls.
- On the menu on the lefthand side click
Contract - Click the sub-option
Interact with Contract
Now on the middle of the screen it asks you for more information about the contract: - Provide the contract's address into the first box.
Now to find the contract's ABI... ('Application Binary Interface'):
If you deployed the contract using truffle, the ABI will be stored in the build folder. If this isn't your contract, you can instead usually pull the ABI from etherscan as follows:
- In a new tab visit etherscan.io
- Navigate to the contract's page by pasting its address in the search box
- Halfway down the screen there's a row of tabs, select Contract
- Scroll down to find
Contract ABI, and copy the contents of this box using the button on the top-right - Now go back to your myetherwallet tab, and paste the contract's ABI into the second box.
- Click
Continue, and myetherwallet will provide you a dropdown list of all of the functions available on the contract - select the function you want to call, and provide any values required for the function
- You'll need to approve the transaction from whichever wallet you connected.
If you didn't deploy the contract, and the contract's ABI hasn't been verified on etherscan, then you may struggle to find it. You may need to contact the person or company who deployed the contract to find a way of interacting with it.
- 76
- 2
