Plasma Light Client API

deposit

deposit(amount: number, tokenContractAddress: string): Promise‹void›

Deposit given amount of token to corresponding deposit contract. this method calls approve method of ERC20 contract and deposit method of Deposit contract.

Parameters:

NameTypeDescription
amountnumberamount to deposit
tokenContractAddressstringtoken contract address to deposit into

Returns: Promise‹void›


transfer

transfer(amount: number, tokenContractAddressString: string, toAddress: string): Promise‹void›

transfer token to new owner. throw if given invalid inputs.

Parameters:

NameTypeDescription
amountnumberamount to transfer
tokenContractAddressStringstring-
toAddressstring-

Returns: Promise‹void›


startWithdrawal

startWithdrawal(amount: number, tokenContractAddress: string): Promise‹void›

Withdrawal process starts from calling this method. Given amount and tokenContractAddress, checks if client has sufficient token amount. If client has sufficient amount, create exitProperty from stateUpdates this client owns, calls claimProperty method on UniversalAdjudicationContract. Store the property in exitList. User can call completeWithdrawal to withdraw actual token after the exitProperty is decided to true on-chain.

Parameters:

NameTypeDescription
amountnumberamount to exit
tokenContractAddressstringtoken contract address to exit

Returns: Promise‹void›


completeWithdrawal

completeWithdrawal(exit: Exit): Promise‹void›

Given exit instance, finalize exit to withdraw token from deposit contract. Client checks if the exitProperty of the exit instance is decided by calling isDecided method of UniversalAdjudicationContract. If the property claim have not been decided yet, call decideClaimToTrue. If the exitProperty had been decided to true, call finalizeExit method of corresponding payout contract.

Parameters:

NameTypeDescription
exitExitExit object to finalize

Returns: Promise‹void›


getBalance

getBalance(): Promise‹Array‹object››

Get current balance of tokens in plasma. All ERC20 tokens including Peth registered by registerCustomToken method or registerToken method are included.

Returns: Promise‹Array‹object››


getPendingWithdrawals

getPendingWithdrawals(): Promise‹Exit[]›

Get pending exit list

Returns: Promise‹Exit[]›


registerToken

registerToken(erc20ContractAddress: string, depositContractAddress: string): void

register ERC20 token. use default ERC20 contract wrapper.

Parameters:

NameTypeDescription
erc20ContractAddressstringERC20 token address to register
depositContractAddressstringdeposit contract address connecting to tokenAddress above

Returns: void