Cannot Read Property Title of Null Mongodb
My teammate has deployed ERC 20 token to rinkeby exam network using the truffle openzeppelin code. Now I wanted to interact with that token by using ABI and the contract address of that token using web3.eth.Contract(ABIcode, contractAddress).
I copy the ABI from the folder called C:...\build\abi\SampleToken.json because from what I understand this is where the ABI of the smart contract volition be and I can just re-create this line and put it in my forepart end lawmaking.
here is my simple JS code so far
import Web3 from "web3"; const App = { web3: null, account: cipher, meta: cipher, ABIcode:[ { "inputs": [ { "internalType": "string", "name": "_name", "blazon": "string" }, { "internalType": "string", "proper noun": "_symbol", "type": "string" }, { "internalType": "uint256", "name": "_initialSupply", "type": "uint256" } ], "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": fake, "inputs": [ { "indexed": true, "internalType": "address", "name": "owner", "blazon": "address" }, { "indexed": true, "internalType": "accost", "name": "spender", "type": "accost" }, { "indexed": false, "internalType": "uint256", "proper noun": "value", "type": "uint256" } ], "name": "Blessing", "type": "consequence" }, { "anonymous": imitation, "inputs": [ { "indexed": truthful, "internalType": "address", "proper name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "blazon": "address" }, { "indexed": false, "internalType": "uint256", "proper noun": "value", "type": "uint256" } ], "name": "Transfer", "type": "result" }, { "inputs": [ { "internalType": "address", "proper noun": "possessor", "type": "address" }, { "internalType": "accost", "name": "spender", "type": "accost" } ], "proper name": "assart", "outputs": [ { "internalType": "uint256", "proper name": "", "blazon": "uint256" } ], "stateMutability": "view", "type": "function", "constant": true }, { "inputs": [ { "internalType": "accost", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "amount", "blazon": "uint256" } ], "name": "corroborate", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "accost", "name": "account", "blazon": "accost" } ], "name": "balanceOf", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "office", "abiding": true }, { "inputs": [], "name": "decimals", "outputs": [ { "internalType": "uint8", "name": "", "type": "uint8" } ], "stateMutability": "view", "blazon": "part", "constant": truthful }, { "inputs": [ { "internalType": "address", "proper noun": "spender", "type": "address" }, { "internalType": "uint256", "name": "subtractedValue", "type": "uint256" } ], "name": "decreaseAllowance", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "blazon": "function" }, { "inputs": [ { "internalType": "address", "name": "spender", "type": "accost" }, { "internalType": "uint256", "proper name": "addedValue", "type": "uint256" } ], "name": "increaseAllowance", "outputs": [ { "internalType": "bool", "proper noun": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "name", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "stateMutability": "view", "type": "function", "abiding": true }, { "inputs": [], "name": "symbol", "outputs": [ { "internalType": "string", "proper name": "", "type": "cord" } ], "stateMutability": "view", "blazon": "function", "constant": true }, { "inputs": [], "proper noun": "totalSupply", "outputs": [ { "internalType": "uint256", "proper noun": "", "type": "uint256" } ], "stateMutability": "view", "type": "part", "constant": truthful }, { "inputs": [ { "internalType": "address", "proper name": "recipient", "type": "address" }, { "internalType": "uint256", "proper noun": "amount", "type": "uint256" } ], "proper name": "transfer", "outputs": [ { "internalType": "bool", "name": "", "blazon": "bool" } ], "stateMutability": "nonpayable", "type": "office" }, { "inputs": [ { "internalType": "accost", "proper noun": "sender", "type": "address" }, { "internalType": "address", "proper noun": "recipient", "type": "accost" }, { "internalType": "uint256", "proper noun": "amount", "type": "uint256" } ], "name": "transferFrom", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "nonpayable", "type": "office" } ], contractAddress: '0x48aFf6290412bD01CBf86896f32cd9de76ffDba0', offset: async function() { const { web3 } = this; try { // get contract case //const networkId = look web3.eth.net.getId(); /*const deployedNetwork = starNotaryArtifact.networks[networkId]; this.meta = new web3.eth.Contract( starNotaryArtifact.abi, deployedNetwork.accost, ); */ this.meta = new web3.eth.Contract(ABIcode, contractAddress); console.log(meta); // get accounts const accounts = await web3.eth.getAccounts(); this.account = accounts[0]; } catch (error) { console.mistake("Could not connect to contract or chain."); } }, // put role call here transferFrom: async function() { const { transferFrom } = this.meta.methods; const ownerWallet = document.getElementById("fromWallet").value; const sendToWallet = document.getElementById("toWallet").value; const tokenSend = document.getElementById("ammountToken").value; look corroborate(ownerWallet, tokenSend).transport({from: ownerWallet}) await transferFrom(owner.ownerWallet, sendToWallet, tokenSend).send({from: ownerWallet}); App.setStatus("token has been send from "+ ownerWallet + " to " + sendToWallet+ " with " + tokenSend + " PHO."); }, }; window.App = App; window.addEventListener("load", async office() { if (window.ethereum) { // use MetaMask's provider App.web3 = new Web3(window.ethereum); look window.ethereum.enable(); // get permission to access accounts } else { console.warn("No web3 detected. Falling back to http://127.0.0.ane:9545. You should remove this fallback when yous deploy alive",); // fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail) App.web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545"),); } App.start(); });
the forepart end should only send the token to a wallet that was chosen and send to another called wallet and with the desired amount.
merely when I ran it, I received an error of this
I believe in that location is something incorrect with the ABI considering it says that the methods in meta are 'null'. I think I can't just re-create it and put it in the front end end code. If then, I exercise not know why. I am new to this.
Source: https://ethereum.stackexchange.com/questions/90330/cannot-read-property-methods-of-null
0 Response to "Cannot Read Property Title of Null Mongodb"
Post a Comment