Skip to main content

IChainPay.sol

The IChainPay Solidity interface facilitates interactions with the ChainPay smart contract. This interface defines functions for automating on-chain payments via the ChainPay contract.

interface IChainPay {
function pay(address recipient, bytes memory signature, bytes memory data) external payable;
function pay(address recipient, address token, uint256 amount, bytes memory signature, bytes memory data) external;
function pay(address recipient, address expectedToken, uint256 expectedTokenAmount, address payingToken, uint256 payingTokenAmount, uint24 fee, bytes memory signature, bytes memory data) external;
function pay(address recipient, address token, uint256 amount, uint24 fee, bytes memory signature, bytes memory data) external payable;
function setSigner(address signer) external;
function contractToggle() external;
}

Paying in BNB, invoice in BNB

function pay(address recipient, bytes memory signature, bytes memory data) external payable;
NameTypeDescription
recipientaddressThe recipient of the payment
signaturebytesA signature validating the transaction. See examples of how to generate it
databytesAdditional data for a possible callback or transaction context. See chainpay.createTransaction or chainpay.createTransactionRaw
msg.valueThe amount of BNB being paid.

Paying in Token, invoice in same Token

function pay(address recipient, address token, uint256 amount, bytes memory signature, bytes memory data) external;
NameTypeDescription
recipientaddressThe recipient of the payment
tokenaddressThe token to be used for payment, and the one expected in the transaction
amountuint256The amount of the specified token to be paid
signaturebytesA signature validating the transaction. See examples of how to generate it
databytesAdditional data for a possible callback or transaction context. See chainpay.createTransaction or chainpay.createTransactionRaw

Invoice in Token/BNB, paying in another Token

function pay(address recipient, address expectedToken, uint256 expectedTokenAmount, address payingToken, uint256 payingTokenAmount, uint24 fee, bytes memory signature, bytes memory data) external;
NameTypeDescription
recipientaddressThe recipient of the payment
expectedTokenaddressThe token expected by the transaction
expectedTokenAmountuint256The amount of the expected token
payingTokenaddressThe token being used for the actual payment
payingTokenAmountuint256The amount of the paying token being used. (Slippage to be added)
feeuint24Pool fee obtained from chainpay.utils.findPool
signaturebytesA signature validating the transaction. See examples of how to generate it
databytesAdditional data for a possible callback or transaction context. See chainpay.createTransaction or chainpay.createTransactionRaw

Paying in BNB, Invoice in Token

function pay(address recipient, address token, uint256 amount, uint24 fee, bytes memory signature, bytes memory data) external payable;
NameTypeDescription
recipientaddressThe recipient of the payment
tokenaddressThe token the transaction expects
amountuint256The amount of the expected token
feeuint24Pool fee obtained from chainpay.utils.findPool
signaturebytesA signature validating the transaction. See examples of how to generate it
databytesAdditional data for a possible callback or transaction context. See chainpay.createTransaction or chainpay.createTransactionRaw
msg.valueThe amount of BNB being paid.

contractToggle()

This function toggles whether msg.sender is a contract. When set to true, the ChainPay smart contract will trigger a callback to your contract that implements the IChainPayReceiver interface after successfully sending the tokens.

setSigner(address)

This function should only be called by smart contracts with contractToggle() set to true. Since smart contracts cannot sign transactions directly, this function allows you to designate a signer that can sign on behalf of the smart contract. This enables smart contracts to receive payments through ChainPay by having the designated signer authorize transactions.