Smart Contract - Read
Read data from a smart contract using its Read functions
Parameters
Contract address
Text
Smart Contract Address
ABI
Text
Action name
Text
Optional parameters
In some cases to read a contract you need to indicate additional parameters
Parameter 1 - Parameter 3
Text
All are optional, if the contract requires 1 parameter, for example a wallet address, set it in the Parameter 1 and leave the rest empty
Events
Contract read
Triggered when the reading data is available in the state.
Unknown Error Occurred
Triggers when reading a contract and something went wrong
States
Contract Read - Result
Text
All results will be converted to text, for example if it is JSON, you will have to parse it using regex or if it is number you will have to convert it to number type
This demo works on BSC chain, it reads the Pancakeswap contract to get the swap price for CAKE to BUSD
More about ABI
- Where to get the ABI
The easiest way is to go directly to etherscan (or other blockchain scanner depends on where the contract is deployed) and search for it using the contract address. Then go to Contract section and search for the Contract ABI and just copy all of that text that you see in the ABI section.
- ABI Syntax
Simply copy and paste it, do not make changes, make sure the double quotes are of standard type and it is not auto replaced by single quote or other types.
Find all contract functions and parameters
Similar to how we found the Contract ABI demonstrated above, while you are in the Contract section on etherscan, open the Read Contract You will see a list of all functions available to read from the contract. Each can be opened and see what parameters it needs if any.
If a parameter is an array type with multiple data, set it all in one parameter by indicating the square brackets, make sure to use double quotes when it is string type. For example: Parameter 1:
Last updated