Skip to content

Latest commit

 

History

History
270 lines (166 loc) · 5.64 KB

IExecAccountModule.md

File metadata and controls

270 lines (166 loc) · 5.64 KB

iexec / Exports / IExecAccountModule

Class: IExecAccountModule

module exposing account methods

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new IExecAccountModule(configOrArgs, options?): IExecAccountModule

Create an IExecModule instance

Parameters

Name Type
configOrArgs IExecConfig | IExecConfigArgs
options? IExecConfigOptions

Returns

IExecAccountModule

Inherited from

IExecModule.constructor

Properties

config

config: IExecConfig

current IExecConfig

Inherited from

IExecModule.config

Methods

approve

approve(amount, spenderAddress): Promise<string>

SIGNER REQUIRED

approves the spender to use the account up to a specified amount, denoted in nRLC (1 nRLC = 1*10^-9 RLC).

example:

const txHash = await approve(amount, spenderAddress);
console.log('tx:', txHash);

Parameters

Name Type
amount NRLCAmount
spenderAddress string

Returns

Promise<string>


checkAllowance

checkAllowance(ownerAddress, spenderAddress): Promise<NRLCAmount>

checks the amount of allowance approved for the specified spender to use the account of the owner.

example:

const allowanceAmount = await checkAllowance(ownerAddress, spenderAddress);
console.log('allowance amount:', allowanceAmount);

Parameters

Name Type
ownerAddress string
spenderAddress string

Returns

Promise<NRLCAmount>


checkBalance

checkBalance(address): Promise<{ locked: BN ; stake: BN }>

check the account balance of specified address (stake is available nRLC, locked is escrowed nRLC)

example:

const balance = await checkBalance(ethAddress);
console.log('Nano RLC staked:', balance.stake.toString());
console.log('Nano RLC locked:', balance.locked.toString());

Parameters

Name Type
address string

Returns

Promise<{ locked: BN ; stake: BN }>


checkBridgedBalance

checkBridgedBalance(address): Promise<{ locked: BN ; stake: BN }>

check the account balance on bridged chain of specified address ie: when connected to mainnet, check the account ballance on bellecour example:

const balance = await checkBridgedBalance(ethAddress);
console.log('Nano RLC staked:', balance.stake.toString());
console.log('Nano RLC locked:', balance.locked.toString());

Parameters

Name Type
address string

Returns

Promise<{ locked: BN ; stake: BN }>


deposit

deposit(amount): Promise<{ amount: BN ; txHash: string }>

SIGNER REQUIRED

deposit some nRLC (1 nRLC = 1*10^-9 RLC) from user wallet to user account

example:

const { amount, txHash } = await deposit('1000000000');
console.log('Deposited:', amount);
console.log('tx:', txHash);

Parameters

Name Type
amount NRLCAmount

Returns

Promise<{ amount: BN ; txHash: string }>


revokeApproval

revokeApproval(spenderAddress): Promise<string>

SIGNER REQUIRED

revokes the approval for the spender to use the account.

example:

const txHash = await revokeApproval(spenderAddress);
console.log('tx:', txHash);

Parameters

Name Type
spenderAddress string

Returns

Promise<string>


withdraw

withdraw(amount): Promise<{ amount: BN ; txHash: string }>

SIGNER REQUIRED

withdraw some nRLC (1 nRLC = 1*10^-9 RLC) from user account to user wallet

example:

const { amount, txHash } = await iexec.account.withdraw('1000000000');
console.log('Withdrawn:', amount);
console.log('tx:', txHash);

Parameters

Name Type
amount NRLCAmount

Returns

Promise<{ amount: BN ; txHash: string }>


fromConfig

fromConfig(config): IExecAccountModule

Create an IExecAccountModule instance using an IExecConfig instance

Parameters

Name Type
config IExecConfig

Returns

IExecAccountModule

Overrides

IExecModule.fromConfig