Create
Programming the trading liquidity
const target_amount = toUint256WithFelts((BigInt('10,000'.replace(/,/g, ''))).toString())
const initial_amount = toUint256WithFelts((BigInt('5,000'.replace(/,/g, ''))).toString())
await buyer.invoke(
txFlowContract,
'approve',
{ spender: txFlowContract.address, amount: initial_amount},
{ maxFee: FEE}
)const {block_number: block, block_timestamp: time} = await account0.call(txFlowContract, "state")
let block_timestamp = new Date(Number(time) * 1000)
let start_timestamp = new Date(block_timestamp)
let start_unixtime = Math.floor(start_timestamp.getTime() / 1000)
let maturity_timestamp = start_timestamp
maturity_timestamp.setMinutes(start_timestamp.getMinutes() + 35)
let maturity_unixtime = Math.floor(maturity_timestamp.getTime() / 1000)
let tokenId = toUint256WithFelts("0")
let txHash = await buyer.invoke(
txFlowContract,
"addNFTMaturityStream",
{
beneficiary_address: txTradeContract.address,
beneficiary_tokenId: tokenId,
target_amount: target_amount,
initial_amount: initial_amount,
start: start_unixtime,
maturity: maturity_unixtime
},
{ maxFee: FEE}
)
console.log('Tx: ', txHash)
let txReceipt = await starknet.getTransactionReceipt(txHash)
let flowId = parseInt(txReceipt['events'][0]['data'][0], 16)
console.log('Flow ID: ', flowId)Last updated