Skip to content

How to migrate DApp to Makki

chengchen edited this page Apr 25, 2019 · 3 revisions

Getting Started

If you're familiar with other browser-based wallets, it's quite similar. We are based on aion-web3 v1.15. Just declare aion-web3 after window.onLoad.
We're handling the following functions as promises :

  • sign(not yet implemented)
  • send
  • getAccounts

Use aionweb3 the same way as web3, You can refer to this tutorial to use it.

Note

In makkii, aionweb3.eth.sendTransaction only return a Promise, It's not support function .on or .once and we also don't support such contract.methods.func().send(), please use eth.sendTransction() instead;

Example

Initializing Contract Instance

window.onLoad(){
 let contractInstance = new aionweb3.eth.Contract(ABI, ADDRESS);
}

Contarct Call Function

contractInstance.methods.functionName(param..).call({}).then((res)=>{
  console.log(res)
})

Contract Send Function

aionweb3.eth.sendTransaction({
   from: aionweb3.eth.accounts.toString(), //required
   to: contractInstance._address,  
   data: contractInstance.methods.functionName().encodeABI(),
   gas: 210000,
}).then((res)=>{
   console.log(res);
})