Hey i want to automate my staking on The Sandbox. For that i need in the first step to interact with the mSand-Matic Pool Contract. It is this one: https://polygonscan.com/address/0x4ab071c42c28c4858c4bac171f06b13586b20f30#code
I have written a little programm in a github repo to show what i have done see here: https://github.com/ChristianErdtmann/mSandMaticStakingAutomation
Or here the code example from the contract-interact.js
Web3 = require('web3')
const fs = require('fs');
const web3 = new Web3("https://polygon-rpc.com")
const contractAddress = "0x4AB071C42C28c4858C4BAc171F06b13586b20F30"
const contractJson = fs.readFileSync('./abi.json')
const abi = JSON.parse(contractJson)
const mSandMaticContract = new web3.eth.Contract(abi, contractAddress)
mSandMaticContract.balanceOf('0x7e5475290Df8E66234A541483453B5503551C780')
The abi i have taken from the contract link on the top. But it seems there is a problem.
I tried for testing to read someting from the contract. For that i used the function balanceOf(address), how you can see in the code.
But i get alltimes the error: TypeError: mSandMaticContract.balanceOf is not a function
Top comments (1)
I found the solution
So the final working code is:
If you additional want to do a write transaction you need the following: