Interacting Smart Contracts
Once a smart contract has been deployed or imported, you can interact with it using our Dashboard or from Code using the Relayer.
The possible interactions are:
- Calling a function of the smart contract (will require gas on the associated blockchain's network).
- Reading the information on the smart contract (usually free of gas), such as reading the balance on an ERC20 contract.
- From Code
- From Webapp
To interact with a smart contract, you can first list all the functions of your smart contracts using:
const axios = require("axios")
const startonAPI = axios.create({
baseURL: "https://api.starton.com",
headers: {
"x-api-key": "YOUR_API_KEY",
},
})
startonAPI
.get("/v3/smart-contract/polygon-mumbai/0xF205506dA3aF8D0Cc0f90D7C0c0eA4EFA6423CFF/available-functions")
.then((res) => console.log(res.data))
.catch((e) => console.log(e))
Then, once you have the right function, you can call it. For example, here, we're trying to mint 1000 new tokens.
const axios = require("axios")
const startonAPI = axios.create({
baseURL: "https://api.starton.com",
headers: {
"x-api-key": "YOUR_API_KEY",
},
})
startonAPI
.post("/v3/smart-contract/polygon-mumbai/0x608B2BC89f569Bf883A6d0A36aDBd8DC937fAf2e/call", {
signerWallet: "0x694F07CEEc0869aa0dB5E8157FA538268F28B23f",
functionName: "mint(address,uint256)",
params: ["0x694F07CEEc0869aa0dB5E8157FA538268F28B23f", "10000000000000"],
})
.then((res) => console.log(res.data))
.catch((e) => console.log(e))
As the number will be read in Gwei, you need to add 18 zeros after the amount of token you want to mint.
You can check your transaction using the transaction hash on your selected network.
Learn more about how to interact with a Smart Contract from Code in our Tutorial section.
- In Smart Contract, select a Smart Contract.
- Select a function.
- Enter the parameters.
- Click Run.
Learn more about how to interact with a Smart Contract from Code in our Tutorial section.
Note that the developer mode is unavailable for third-party wallets
Smart contract functions
Read Smart Contracts references for more information on how to call smart contract functions.
info
When interacting with smart contracts on Dashboard, you can use the search feature to browse your read, write and payable functions.
Related topics
- More on Transactions
- More on Smart Contracts
- More on Developer mode