Loading...
In the context of Ethereum, refers to decentralized apps that run on the blockchain. These are apps that allow anyone to participate without monetizing their personal data.
A Javascript representation of the smart contra we want to interact with or a way to call the function on the smart contract when reading the data.
We can get a Javascript representation of an Ethereum smart contract with the web.eth.Contract() function. This function expects two arguments: one for the smart contract ABI and one of the smart contract address.
A smart contract ABI stands for "Abstract Binary Interface", and is a JSON array that describes how a specific smart contract works.
They have two parameters stored in the contract variable the one is the current smart contract address and the ABI file.
Example:
const abi = // paste you ABI file
const account = ' ' // paste you contract address
const contract = new.web3.eth.Contract(abi,address)
If you read data from the smart contract by calling its function. All of the smart contract functions are listed under contract.methods
const Web3 = require('web3')
const rpcURL = '' // Your RCP URL goes here
const web3 = new Web3(rpcURL)
const abi = // abi value
const address = ' ' // contract address
const contract = new web3.eth.Contract(abi, address)
contract.methods.totalSupply().call((err, result) => { console.log(result) })
contract.methods.name().call((err, result) => { console.log(result) })
contract.methods.symbol().call((err, result) => { console.log(result) })
contract.methods.balanceOf('0xd26114cd6EE289AccF82350c8d8487fedB8A0C07').call((err, result) => { console.log(result) })