As the interaction is directly on-chain, this is not an endpoint. Steps to create a PAWN 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 PAWN plans but interacting with the Cyan Protocol as well.
Prior to creating a PAWN Plan, the user must grant Cyan the approval to move the NFT. To receive the user's approval, please call the
approve
function of the NFT or when using the SDK, just call theGet Approval
method.
In order to create a new PAWN Plan, call the createPAWNPaymentPlan
function from the smart contract with data retrieved from the endpoint Retrieve a calculated PAWN plan
createPAWNPaymentPlan
function accepts the following parameters:
Fields | Description |
---|---|
wNFTContract | Cyan Wrapper address of the collection |
wNFTTokenId | NFT id |
amount | Borrowed amount of ETH (BigNumber ) for Pawning |
interestRate | Interest rate by pricer calculation |
signedBlockNum | Last block number |
term | Interval between payments |
serviceFeeRate | Fee rate of the service. |
totalNumberOfPayments | Total number of payments to be made |
signature | Signature created and provided by Cyan |
Example:
const signer = this.provider.getSigner();
const appraisal = { .... } // from Retrieve calculated Pawn plan
const contract = new Contract(
paymentContractAddress, // Cyan payment contract address
abi // Cyan ABI
signer // signer from Web3
);
const transaction = await contract.createPAWNPaymentPlan(
appraisal.wrapperAddress,
appraisal.tokenId,
appraisal.unlockAmount,
appraisal.interestRate,
appraisal.lastBlockNum,
appraisal.term,
appraisal.serviceFeeRate,
appraisal.totalNumOfPayments,
appraisal.signature
);