Wallet Setup
Set up a wallet for contract deployment and execution
Last updated
Was this helpful?
Set up a wallet for contract deployment and execution
Last updated
Was this helpful?
Developers can manage Ethereum wallet private keys using the MetaMask browser add-on.
MetaMask is a non-custodial wallet. The user's private key is encoded with the mnemonic phrase and stored in user's local browser. Once lost, the user can no longer control the savings or restore access to the wallet. MetaMask communicates with Ethereum Ledger via Infura. Please refer to the for more details.
First, install the following in your dApp:
Create a new file, name it web3.js and insert the following code in it:
To put it simply, you can inject the global object ethereum
if you have added MetaMask to Chrome.
Next, import the code as below:
Call the function:
We need an account from the web3 instance we created above to send transactions.
The getAccounts()
function returns all the user’s Metamask accounts, whileaccounts[0]
is the one currently selected by the user.
Initialize your contract after completing above steps.
Now you can call any function by directly interacting with the instantiated contract. Please note that:
Functions that do not alter the state of the contract are call()
functions. Below is an example of calling a call()
function:
Functions that alter the state of the contract are send()
functions. Below is an example of calling a send()
function:
Ontology supports developers to conduct cross-chain asset transfer using .