Extends¶
Constructor¶
constructor(extension)
Parameter
extension
-MetamaskExtension
Property¶
extension¶
Type: MetamaskWrapper
Description: Metamask wrapper instance passed by constructor.
Methods¶
loadContract¶
async loacContract(abi, address)
Description
Load smart contract to a ContractWrapper instance.
Parameters :
abi
-Array
:ABI Array of Ethereum smart contract.
address
-String
:Smart contract Address.
Returns :
Promise<Result<ContractWrapper, Status>>
:ContractWrapper instance will be set into the data field of Result if Status is SUCCESS.
transfer¶
async transfer(to, amount, memo, extra)
Description
Transfer ETH.
Parameters :
to
-String
:Transfer target address.
amount
-Number
:How many ETH will be transferred.
memo
-String
:Input data of the Transaction on Ethereum.
extra
-TransactionExtraInfo
:Transaction extra data, such as gas, gas limit etc.
Returns :
Promise<Result<ContractWrapper, Status>>
:Transaction hash will be set into the data field of Result if Status is SUCCESS.
transferToken¶
async transferToken(wrapper, to, amount, extra)
Description
Transfercontract based token, such as ERC 20 token.
Parameters :
wrapper
-ContractWrapper
:A ContractWrapper instance returned by loadContract method.
to
-String
:Token transfer target address.
amount
-Number
How many tokens will be transferred.
extra
-TransactionExtraInfo
:Transaction extra data, such as gas, gas limit etc.
Returns :
Promise<Result<ContractWrapper, Status>>
:Transaction hash will be set into the data field of Result if Status is SUCCESS.
getAccount¶
async getAccount()
Description
Get selected account in MetaMask.
Returns :
Promise<Result<String, Status>>
:Account string will be set into the data field of Result if Status is SUCCESS.