Ethereum, Celo, Klaytn
tip
Ethers
Params
new ethers.Contract( address , abi , providerOrSigner )
- address - String: A contract address to be requested
- abi - Object: JSON interface for contracts
- providerOrSigner : A provider or signer that is instantiated by constructor
// Read-Only; By connecting to a Provider, allows:
// - Any constant function
// - Querying Filters
// - Populating Unsigned Transactions for non-constant methods
// - Estimating Gas for non-constant (as an anonymous sender)
// - Static Calling non-constant methods (as anonymous sender)
const myContract = new ethers.Contract(address, abi, provider);
// Read-Write; By connecting to a Signer, allows:
// - Everything from Read-Only (except as Signer, not anonymous)
// - Sending transactions for non-constant functions
const myContract_rw = new ethers.Contract(address, abi, signer);
web3.js
Params
new web3.eth.Contract(jsonInterface[, address][, options])
- jsonInterface - Object: JSON interface for contracts
- address - String (optional): A contract address to be requested
- options - Object (optional): The options for a contract
- from - String: The address that sends a transaction
- gasPrice - String: Gas price to be payed in a transaction
- gas - Number: gas limit
- data - String: Contract Bytecode
const myContract = new web3.eth.Contract([...], '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', {
from: '0x1234567890123456789012345678901234567891', // default from address
gasPrice: '20000000000' // default gas price in wei, 20 gwei in this case
});
info
Visit the official docs for further information.