ContractProvider¶
ContractProvider is a wrapper that interacts with the plasma chain smart contract.
address¶
contract.address
Returns the contract’s address.
Returns¶
string: Address of the connected contract.
hasAddress¶
contract.hasAddress
Whether or not the contract has an address.
Returns¶
boolean: true if the contract is ready to be used, false otherwise.
ready¶
contract.ready
Whether or not the contract is ready to be used.
Returns¶
boolean: true if hte contract is ready, false otherwise.
web3¶
contract.web3
Returns the web3 instance being used by the contract.
Returns¶
Web3: Contract’s web3 instance.
plasmaChainName¶
contract.plasmaChainName
Name of the plasma chain this contract is connected to.
Returns¶
string: Plasma chain name.
checkAccountUnlocked¶
contract.checkAccountUnlocked(address)
Checks whether an account is unlocked and attempts to unlock it if not.
Parameters¶
address-string: Address of the account to check.
getBlock¶
contract.getBlock(block)
Queries the hash of a given block.
Parameters¶
block-number: Number of the block to query.
Returns¶
Promise<string>: Root hash of the block with that number.
getNextBlock¶
contract.getNextBlock()
Returns the number of the next block that will be submitted.
Returns¶
Promise<number>: Next block number.
getCurrentBlock¶
contract.getCurrentBlock()
Returns the number of the last block to be submitted.
Returns¶
Promise<number>: Last block number.
getOperator¶
contract.getOperator()
Returns the address of the operator.
Returns¶
Promise<string>: Plasma chain operator address.
getTokenAddress¶
contract.getTokenAddress(token)
Returns the address for a given token ID.
Parameters¶
token-string: A token ID.
Returns¶
Promise<string>: Address of the contract for that token.
listToken¶
contract.listToken(tokenAddress)
Lists a token with the given address so that it can be deposited.
Parameters¶
tokenAddress-string: Address of the token to list.
Returns¶
EthereumTransaction: The Ethereum transaction result.
getChallengePeriod¶
contract.getChallengePeriod()
Returns the current challenge period in number of blocks.
Returns¶
Promise<number>: Challenge period.
getTokenId¶
contract.getTokenId(tokenAddress)
Gets the token ID for a specific token.
Parameters¶
tokenAddress-string: Token contract address.
Returns¶
Promise<string>: ID of the token.
depositValid¶
contract.depositValid(deposit)
Checks whether a Deposit actually exists. Used when checking transaction proofs.
Returns¶
boolean: true if the deposit exists, false otherwise.
deposit¶
contract.deposit(address, token, amount)
Deposits some value of a token to the plasma smart contract.
Parameters¶
1. address - string: Address to deposit with.
1. token - string: Address of the token to deposit.
2. amount - number: Amount to deposit.
Returns¶
EthereumTransaction: An Ethereum transaction receipt.
startExit¶
contract.startExit(block, token, start, end, owner)
Starts an exit for a user. Exits can only be started on transfers, meaning you need to specify the block in which the transfer was received.
Parameters¶
block-BigNum: Block in which the transfer was received.token-BigNum: Token to be exited.start-BigNum: Starts of the range received in the transfer.end-BigNum: End of the range received in the transfer.owner-string: Address to withdraw from.
Returns¶
EthereumTransaction: Exit transaction receipt.
finalizeExit¶
contract.finalizeExit(exitId, exitableEnd, owner)
Finalizes an exit for a user.
Parameters¶
exitId-string: ID of the exit to finalize.exitableEnd-BigNum: The “exitable end” for that exit.owner-string: Address that owns the exit.
Returns¶
EthereumTransaction: Finalization transaction receipt.