ex_plasma v0.1.0 ExPlasma.Client

This module provides functions to talk to the contract directly.

Link to this section Summary

Functions

Adds an exit queue for the given vault and token address.

Deposit a transaction to the contracts.

Process exits in Plasma. This will allow you to process your a specific exit or a set number of exits.

Submits a block to the contract.

Link to this section Functions

Link to this function

add_exit_queue(vault_id, token_address, options \\ %{})

add_exit_queue(non_neg_integer(), binary(), map()) :: tuple()

Adds an exit queue for the given vault and token address.

Link to this function

deposit(tx_bytes, options \\ %{})

deposit(ExPlasma.Transaction.t() | binary(), map() | list()) :: tuple()

Deposit a transaction to the contracts.

Examples

Deposit 1 ETH to the contracts.

alias ExPlasma.Client alias ExPlasma.Utxo alias ExPlasma.Transaction.Deposit

owner_address = "0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b" currency_address = "0x0000000000000000000000000000000000000000"

%Utxo{owner: owner_address, currency_address: currency_address, amount: 1} |> Deposit.new() |> Client.deposit()

Link to this function

process_exits(exit_id, options)

process_exits(non_neg_integer(), map()) :: tuple()

Process exits in Plasma. This will allow you to process your a specific exit or a set number of exits.

Link to this function

start_standard_exit(tx_bytes, options)

start_standard_exit(binary(), map()) :: tuple()

Start a Standard Exit

  • tx_bytes - The encoded hash of the transaction that created the utxo.
  • owner - Who's starting the standard exit.
  • utxo_pos - The position of the utxo.
  • proof - The merkle proof.
  • output_guard_pre_image - TBD

Example

%Utxo{owner: owner_address, currency_address: currency_address, amount: 1} |> Deposit.new() |> Transaction.encode() |> Client.start_standard_exit(%{

 from: authority_address(),
 utxo_pos: utxo_pos,
 proof: proof

})

Link to this function

submit_block(block_hash, options \\ %{})

submit_block(ExPlasma.Block.t() | String.t(), map()) :: tuple()

Submits a block to the contract.

Example

input_utxo = %Utxo{blknum: 0, oindex: 0, txindex: 0} output_utxo = %Utxo{owner: owner_address, currency: currency_address, amount: 1} payment = Payment.new(%{inputs: [input_utxo], outputs: [output_utxo]})

[payment] |> Block.new() |> Client.submit_block()