Shifter

Definitions

Native

  • We define a native blockchain to be the blockchain on which tokens originate. For example, when Bitcoin is sent to an Ethereum contract, Bitcoin is considered the native blockchain.

  • We define native addresses to be addresses on the native blockchain. In our example, Bitcoin addresses would be considered native addressed.

Host

  • We define a host blockchain as the complement to the native blockchain; it is the blockchain to which tokens are shifted. For example, when Bitcoin is sent to an Ethereum contract, Ethereum is considered the host blockchain.

  • We define host addresses to be addresses on the host blockchain. In our example, Ethereum addresses would be considered host addresses.

Events

ShiftedIn

event ShiftedIn(bytes _to, uint256 _amount, bytes _nonce, bytes _payloadHash);

The shiftIn function must emit a ShiftedIn event when tokens have been successfully sent from a native blockchain to a host blockchain.

Argument

Description

_to

The host address to which the tokens were sent.

_amount

The amount of tokens that were sent. This is denominated in units of 1e-18.

_nonce

_payloadHash

ShiftedOut

event ShiftedOut(bytes _to, uint256 _amount);

The shiftOut function must emit a ShiftedOut event when tokens are being sent from the host blockchain back to their native blockchain. RenVM must observe ShiftedOut events and react by sending tokens on the native blockchain to the specified native address.

Argument

Description

_to

The native address to which the tokens will be sent.

_amount

The amount of tokens that will be sent. This is denominated in units of 1e-18.

Functions

Shifting In

function shiftIn(bytes _to, uint256 _amount, bytes _nonce, bytes _payloadHash, bytes _sig) external returns (bool _ok);

The shiftIn function is used to send tokens from their native blockchain to a host blockchain. Before calling this function, a transaction must send tokens to RenVM on the native blockchain. This lets RenVM control the conditions under which these tokens can be accessed again. Once the transaction has been confirmed on the native blockchain, RenVM will produce the required signature for shifting and this function can be called. This function makes a payment to the DarknodePayment contract that is proportional to the amount being shifted.

Argument

Description

_to

A host address to which the tokens will be sent.

_amount

An amount of tokens that will be sent. The number of decimals matches the host token.

_nonce

_payloadHash

_sig

A signature on keccak256("ShiftIn(_to,_amount,_tx,_payloadHash)") produced by RenVM.

Return

Description

_ok

A boolean that defines the success, or failure, of the shift.

Shifting Out

function shiftOut(bytes _to, uint256 _amount) external returns (bool _ok);

The shiftOut function is used to send tokens from a host blockchain back to their native blockchain. After observing the respective ShiftedOut event, RenVM will sign a transaction that will send tokens to the specified native address. This function makes a payment to the DarknodePayment contract that is proportional to the amount being shifted.

Argument

Description

_to

A native address to which the tokens will be sent.

_amount

An amount of tokens that will be sent. Denominated in 1e-18 units.

Return

Description

_ok

A boolean that defines the success, or failure, of the shift.