1.0.9 • Published 4 years ago
showpay-nft-auction-js v1.0.9
sensible-nft 拍卖合约
需求:
 用于nftonshow上的nft拍卖,拍卖者设定一个时间,在此期间内可以竞拍,时间到了后结束拍卖,nft转移到竞拍者,bsv转移到拍卖者。
 nft使用sensible协议,时间oracle使用aaron的witnessonchain。
简介:
 拍卖合约是基于sensible BCP-01( 94b4013)的拓展合约
 新增的合约:nftAuction.scrypt nftForAuction.scrypt nftAuctionProto.scrypt nftForAuctionProto.scrypt (**Proto.scrypt用于操作datapart部分)
datapart: (type specific data) + (proto header)
 type specific data:
	<proto_version(4 bytes)> + <proto_type(4 bytes)> + <'sesible'(8 bytes)>
 nftAuction type specific data:
	<sensibleId(36byte)> +
    <bidderAddress(20byte)> +
    <bidBsvPrice>(8byte) +
    <bidTimestamp>(8byte) +
    <sendderAddress(20byte)> +
    <startBsvPrice(8byte)> +
    <feeAddress>(20byte) +
    <feeRate>(1byte) +
    <nftCodeHash>(20byte) +
    <nftID>(20byte) + 
    <endTimeStamp>(8byte) +
    <timeRabinPubkeyHash>(20byte)
    <rabinPubKeyHashArrayHash>(20byte) nftForAuction.scrypt type specific data:
	<nftCodeHash>(20 bytes) +
	<nftID>(20 bytes) +
    <auctionContractHash> (20 bytes)拍卖上架:
1. 生成 NftAuction合约,datapart部分有bidPrice和bidderAddress,是个有状态合约
2. 生成 NftForAuction 合约,该合约datapart部分不作改变,是个无状态合约
3. 将拍卖的nft转移到第二步生成的合约地址
拍卖竞价:
输入原NftAuction utxo,   改变  datapart 的 bidPrice 和 bidderAddress 生成新utxo
拍卖完成:
	输入 NftAuction、NftForAuction、nftUnlockingContractCheck,输出nft、p2pkh(bsv to sender)oracle:
 竞价和解锁引入了两种oracle,分别是satotx和witnessonchain。satotx用于做utxo的溯源,witnessonchain用于获取当前时间
