As the interaction is directly on-chain, this is not an endpoint. Steps to create a BNPL plan are detailed below!
For the best experience, please refer to the SDK documentation. You'll be able to install our library and get started in not only creating BNPL plans but interacting with the Cyan Protocol as well.
In order to create a BNPL plan, call the createBNPLPaymentPlan
function from the smart contract with data retrieved from the endpoint Retrieve a calculated BNPL plan.
createBNPLPaymentPlan
function accepts the following parameters:
Fields | Description |
---|---|
address | Cyan Wrapper address of the collection |
tokenId | NFT id |
amount | Price of the listing |
interestRate | Interest fee by rate |
signedBlockNum | The last block number |
term | Interval between payments, expressed in seconds |
serviceFeeRate | Fee rate of the service. |
totalNumberOfPayments | How many payments need to be made. |
signature | Signature created and provided by Cyan |
Example:
const signer = this.provider.getSigner();
const calculatedData = {...} // from Retrieve a Calculated BNPL Plan
const contract = new Contract(
paymentContractAddress, // Cyan payment contract address
abi // Cyan ABI
signer // signer from Web3
);
const transaction = await contract.createBNPLPaymentPlan(
calculatedData.wrapperAddress,
calculatedData.tokenId,
calculatedData.price,
calculatedData.interestRate,
calculatedData.lastBlockNum,
calculatedData.term,
calculatedData.serviceFeeRate,
calculatedData.totalNumOfPayments,
calculatedData.signature,
{ value: calculatedData.downpaymentAmount }
);