Skip to content

Latest commit

 

History

History
281 lines (210 loc) · 12.4 KB

wallet.md

File metadata and controls

281 lines (210 loc) · 12.4 KB

nahmii-sdk

Wallet ⏏

Wallet A class for performing various operations on a wallet.

Kind: Exported class

new Wallet(signer, provider)

Create a Wallet from either a private key or custom signing functions

Param Type Description
signer string | object A private key, or information required for the wallet to have signing capabilities
provider NahmiiProvider A NahmiiProvider instance

wallet.provider ⇒ NahmiiProvider

The Nahmii Provider used by this wallet instance.

Kind: instance property of Wallet

wallet.address ⇒ String

Returns the address for this wallet, required by ethers Wallet methods.

Kind: instance property of Wallet

wallet.signerKey ⇒ ethers.SignerKey | undefined

If used with software wallet, returns an object containing signer related information and logic such as the private key, otherwise undefined

Kind: instance property of Wallet
Returns: ethers.SignerKey | undefined - The private key or undefined

wallet.getNahmiiBalance() ⇒ Promise

Retrieves available nahmii balance for current wallet.

Kind: instance method of Wallet
Returns: Promise - A promise that resolves into a mapping from symbol to human readable amount.

wallet.getNahmiiStagedBalance(symbol) ⇒ Promise.<BigNumber>

Retrieves nahmii staged balance for a currency of the current wallet.

Kind: instance method of Wallet

Param Type Description
symbol string The currency symbol

wallet.getReceipts([fromNonce], [limit], [asc]) ⇒ Promise

Retrieves all receipts for effectuated payments for the wallet using filter/pagination criteria.

Kind: instance method of Wallet
Returns: Promise - A promise that resolves into an array of payment receipts

Param Type Default Description
[fromNonce] number Filter payment receipts greater or equal to specific nonce.
[limit] number The max number of payment receipts to return.
[asc] boolean false Return payment receipts in asc order.

wallet.depositEth(amountEth, [options]) ⇒ Promise

Initiates the deposit of ETH from the on-chain balance of the wallet to nahmii.

Kind: instance method of Wallet
Returns: Promise - A promise that resolves into a transaction with a hash.

Param Type Description
amountEth number | string The amount of ETH to deposit.
[options]

Example

const {hash} = await wallet.depositEth('1.1', {gasLimit: 200000});
const receipt = await wallet.provider.getTransactionConfirmation(hash);

wallet.getDepositAllowance(symbol) ⇒ Promise.<BigNumber>

Retrieve current deposit allowance for the specified symbol.

Kind: instance method of Wallet

Param Type Description
symbol string The currency symbol

wallet.approveTokenDeposit(amount, symbol, [options]) ⇒ Promise

Initiates the deposit of a token from the wallet's on-chain balance to nahmii by calling the approve method of the token smart contract.

Kind: instance method of Wallet
Returns: Promise - A promise that resolves into a transaction with a hash.
See: https://docs.ethers.io/ethers.js/html/api-providers.html#transaction-receipts

Param Type Description
amount number | string The amount of currency to deposit.
symbol string The currency symbol
[options]

Example

const {hash} = await wallet.depositToken('1.1', 'HBT', {gasLimit: 200000});
const receipt = await wallet.provider.getTransactionConfirmation(hash);

wallet.completeTokenDeposit(amount, symbol, [options]) ⇒ Promise

Initiates the completion of a deposit of a token from a wallet's on-chain balance to nahmii by calling the depositTokens method of the nahmii clientFund smart contract. Requires approveTokenDeposit to have been called first.

Kind: instance method of Wallet
Returns: Promise - A promise that resolves into a transaction with a hash.

Param Type Description
amount number | string The amount of currency to deposit.
symbol string The currency symbol
[options]

Example

const {hash} = await wallet.completeTokenDepsoit('1.1', 'HBT', {gasLimit: 200000});
const receipt = await wallet.provider.getTransactionConfirmation(hash);

wallet.withdraw(monetaryAmount, [options]) ⇒ Promise

Withdraw an amount of ETH or ERC20 tokens from nahmii to base layer.

Kind: instance method of Wallet
Returns: Promise - A promise that resolves into transaction hash.

Param Type Description
monetaryAmount MonetaryAmount The amount to withdraw from nahmii.
[options]

Example

let amountBN = ethers.utils.parseUnits('1.1', 18);
let currency = '0x0000000000000000000000000000000000000000'
let monetaryAmount = new nahmii.MonetaryAmount(amountBN, currency, 0)
let hashObj = await wallet.withdraw(monetaryAmount, {gasLimit: 200000});

wallet.unstage(monetaryAmount, [options]) ⇒ Promise

Unstage an amount of ETH or ERC20 tokens from staged balance back to nahmii available balance.

Kind: instance method of Wallet
Returns: Promise - A promise that resolves into transaction hash.

Param Type Description
monetaryAmount MonetaryAmount The amount unstage from staged balance.
[options]

Example

let amountBN = ethers.utils.parseUnits('1.1', 18);
let currency = '0x0000000000000000000000000000000000000000'
let monetaryAmount = new nahmii.MonetaryAmount(amountBN, currency, 0)
let hashObj = await wallet.unstage(monetaryAmount, {gasLimit: 200000});

wallet.getAddress() ⇒ Promise.<string>

Retrieves the wallet address.

Kind: instance method of Wallet
Returns: Promise.<string> - - The wallet address as a hexadecimal string

wallet.signMessage(message) ⇒ Promise.<string>

Signs message and returns a Promise that resolves to the flat-format signature. If message is a string, it is converted to UTF-8 bytes, otherwise it is preserved as a binary representation of the Arrayish data.

Kind: instance method of Wallet

Param
message

wallet.sign(transaction) ⇒ Promise.<string>

Signs transaction and returns a Promise that resolves to the signed transaction as a hex string. In general, the sendTransaction method is preferred to sign, as it can automatically populate values asynchronously.

Kind: instance method of Wallet

Param
transaction

wallet.getBalance([blockTag]) ⇒ Promise.<BigNumber>

Returns the wallet instance on-chain ETH balance

Kind: instance method of Wallet

Param Type Description
[blockTag] string A block number to calculate from

wallet.getTransactionCount([blockTag]) ⇒ Promise.<number>

Returns the wallet instance on-chain transaction count

Kind: instance method of Wallet

Param Type Description
[blockTag] string A block number to calculate from

wallet.sendTransaction(transaction) ⇒ Promise.<TransactionResponse>

Sends the transaction to the network and returns a Promise that resolves to a Transaction Response. Any properties that are not provided will be populated from the network. See: https://docs.ethers.io/ethers.js/html/api-providers.html#transaction-request

Kind: instance method of Wallet

Param Type Description
transaction object An unsigned Ethereum transaction