EVM deployed and now what?
Read hours of the docs.astar.network but unfortunately could not find an answer to my simple Question: how I can use the ready deployed EVM smart contract build and tested on remix.ethereum.org …
So for someone with a similar questions:
dAPP with javaSkript (snippets) …
- done the MetaMask onbording
const onboarding = new MetaMaskOnboarding();
onboarding.startOnboarding();
-I took the ABI and created the Contract
const contract = new web3.eth.Contract(contractABI, contractAddress);
-
requsted the MetaMask Wallet
let accounts = await web3.eth.requestAccounts().catch((err) ; -
prepared the RPC Call
const rpcmethod = contract.methods.myMethod().encodeABI(); -
do the call
await web3.eth.call({
to: contractAddress,
data: rpcmethod,
}); -
wait for response:
resnum = web3.utils.hexToNumber(result);
or a whole structure
res = web3.eth.abi.decodeParameters(abistruct,result);
amount = Number(web3.utils.fromWei(res[“amount”], ‘ether’)).toFixed(6);
payout = Number(web3.utils.fromWei(res[“payout”], ‘ether’)).toFixed(6);
If you have more suggestions or questions, please comment.