BancorX

Group BancorX

Modules > BancorX

The BancorX contract allows cross chain token transfers. More...

Modules

Type

Name

module

Amounts Table This table quantities for cross-transfers.

module

Reporters Table This table stores the account names of BancorX reporters !

module

Transfers Table This table stores transfer stats.

module

Settings Table This table stores settings for cross-transfers.

Public Functions

Type

Name

ACTION

addreporter (name reporter) adds a new reporter, can only be called by the contract account

ACTION

clearamount (uint64_t x_transfer_id) closes row in amounts table, can only be called by bnt token contract or self

ACTION

enablerpt (bool enable) can only be called by the contract account

ACTION

enablext (bool enable) can only be called by the contract account

ACTION

init (name x_token_name, uint64_t min_reporters, uint64_t min_limit, uint64_t limit_inc, uint64_t max_issue_limit, uint64_t max_destroy_limit) initializes the contract settings

void

on_transfer (name from, name to, asset quantity, string memo) transfer intercepts with standard transfer args

ACTION

reporttx (name reporter, string blockchain, uint64_t tx_id, uint64_t x_transfer_id, name target, asset quantity, string memo, string data) reports an incoming transaction from a different blockchain

ACTION

rmreporter (name reporter) removes an existing reporter, can only be called by the contract account

ACTION

update (uint64_t min_reporters, uint64_t min_limit, uint64_t limit_inc, uint64_t max_issue_limit, uint64_t max_destroy_limit) updates the contract settings

Macros

Type

Name

define

EMIT_DESTROY_EVENT (from, quantity) triggered when account tokens are destroyed after cross chain transfer initiation

define

EMIT_ISSUE_EVENT (target, quantity) triggered when enough reports arrived and tokens are issued to an account and the cross chain transfer is fulfilled

define

EMIT_TX_REPORT_EVENT (reporter, blockchain, transaction, target, quantity, x_transfer_id, memo) triggered when a reporter reports a cross chain transfer from another blockchain

define

EMIT_X_TRANSFER_COMPLETE_EVENT (target, id) triggered when final report is succesfully submitted

define

EMIT_X_TRANSFER_EVENT (blockchain, target, quantity, id) triggered when an account initiates a cross chain transafer

Detailed Description

There are two processes that take place in the contract:

  • Initiate a cross chain transfer to a target blockchain (destroys tokens from the caller account on EOS)

  • Report a cross chain transfer initiated on a source blockchain (issues tokens to an account on EOS) Reporting cross chain transfers works similar to standard multisig contracts, meaning that multiple callers are required to report a transfer before tokens are issued to the target account.

Public Functions Documentation

ACTION addreporter (
name reporter
)

Parameters:

  • reporter - name of the reporter

ACTION clearamount (
uint64_t x_transfer_id
)

Parameters:

  • x_transfer_id - the transfer id

ACTION enablerpt (
bool enable
)

Parameters:

  • enable - true to enable reporting (and thus issuance), false to disable it

ACTION enablext (
bool enable
)

Parameters:

  • enable - true to enable cross chain transfers, false to disable them

ACTION init (
name x_token_name,
uint64_t min_reporters,
uint64_t min_limit,
uint64_t limit_inc,
uint64_t max_issue_limit,
uint64_t max_destroy_limit
)

can only be called once, by the contract account

Parameters:

  • x_token_name - cross chain token account

  • min_reporters - minimum required number of reporters to fulfill a cross chain transfer

  • min_limit - minimum amount that can be transferred out (destroyed)

  • max_issue_limit - maximum amount that can be issued on EOS in a given timespan

  • max_destroy_limit - maximum amount that can be transferred out (destroyed) in a given timespan

void on_transfer (
name from,
name to,
asset quantity,
string memo
)

if the token received is the cross transfers token, initiates a cross transfer

Parameters:

  • from - the sender of the transfer

  • to - the receiver of the transfer

  • quantity - the quantity for the transfer

  • memo - the memo for the transfer

ACTION reporttx (
name reporter,
string blockchain,
uint64_t tx_id,
uint64_t x_transfer_id,
name target,
asset quantity,
string memo,
string data
)

can only be called by an existing reporter

Parameters:

  • reporter - reporter account

  • blockchain - name of the source blockchain

  • tx_id - unique transaction id on the source blockchain

  • x_transfer_id - unique (if non zero) pre-determined id (unlike _txId which is determined after the transactions been mined)

  • target - target account on EOS

  • quantity - amount to issue to the target account if the minimum required number of reports is met

  • memo - memo to pass in in the transfer action

  • data - custom source blockchain value, usually a string representing the tx hash on the source blockchain

ACTION rmreporter (
name reporter
)

Parameters:

  • reporter - name of the reporter

ACTION update (
uint64_t min_reporters,
uint64_t min_limit,
uint64_t limit_inc,
uint64_t max_issue_limit,
uint64_t max_destroy_limit
)

can only be called by the contract account

Parameters:

  • min_reporters - new minimum required number of reporters

  • min_limit - new minimum limit

  • limit_inc - new limit increment

  • max_issue_limit - new maximum incoming amount

  • max_destroy_limit - new maximum outgoing amount

Macro Definition Documentation

#define EMIT_DESTROY_EVENT (
from,
quantity
) START_EVENT("destroy", "1.1") \
EVENTKV("from",from) \
EVENTKVL("quantity",quantity) \
END_EVENT()

#define EMIT_ISSUE_EVENT (
target,
quantity
) START_EVENT("issue", "1.1") \
EVENTKV("target",target) \
EVENTKVL("quantity",quantity) \
END_EVENT()

#define EMIT_TX_REPORT_EVENT (
reporter,
blockchain,
transaction,
target,
quantity,
x_transfer_id,
memo
) START_EVENT("txreport", "1.2") \
EVENTKV("reporter",reporter) \
EVENTKV("from_blockchain",blockchain) \
EVENTKV("transaction",transaction) \
EVENTKV("target",target) \
EVENTKV("quantity",quantity) \
EVENTKV("x_transfer_id",x_transfer_id) \
EVENTKVL("memo",memo) \
END_EVENT()

#define EMIT_X_TRANSFER_COMPLETE_EVENT (
target,
id
) START_EVENT("xtransfercomplete", "1.2") \
EVENTKV("target", target) \
EVENTKVL("id", id) \
END_EVENT()

#define EMIT_X_TRANSFER_EVENT (
blockchain,
target,
quantity,
id
) START_EVENT("xtransfer", "1.2") \
EVENTKV("blockchain",blockchain) \
EVENTKV("target",target) \
EVENTKV("quantity",quantity) \
EVENTKVL("id",id) \
END_EVENT()