contract Badge{ Ripemd160 pubKeyHash; constructor(Ripemd160 pubKeyHash){ this.pubKeyHash = pubKeyHash; } public function unlock(Sig sig,PubKey pubKey,bytes badgeFlag){ require(badgeFlag == b'6261646765'); require(hash160(pubKey) == this.pubKeyHash); require(checkSig(sig,pubKey)); } }
contract Badge{ Ripemd160 pubKeyHash; constructor(Ripemd160 pubKeyHash){ this.pubKeyHash = pubKeyHash; } public function unlock(Sig sig,PubKey pubKey,bytes badgeFlag){ require(badgeFlag == b'6261646765'); require(hash160(pubKey) == this.pubKeyHash); require(checkSig(sig,pubKey)); } }
import "util.scrypt"; contract Nft { public function unlock(Sig sig, PubKey senderPubKey, SigHashPreimage txPreimage, Ripemd160 p2pkhReceiver1, int p2pkhAmount1, Ripemd160 nftReceiver, int nftAmount, Ripemd160 p2pkhReceiver2, int p2pkhAmount2, Ripemd160 p2pkhReceiver3, int p2pkhAmount3) { bytes lockingScript = Util.scriptCode(txPreimage); int scriptLen = len(lockingScript); int pubkeyHashStart = scriptLen - Util.PubKeyHashLen; Ripemd160 senderPubkeyHash = Ripemd160(lockingScript[pubkeyHashStart :]); bytes codePart = lockingScript[: pubkeyHashStart]; bytes outputs = b''; if (p2pkhAmount1 > 0) { bytes outputScript = Util.buildPublicKeyHashScript(p2pkhReceiver1); bytes output = Util.buildOutput(outputScript, p2pkhAmount1); outputs += output; } if (nftAmount > 0) { bytes outputScript = codePart + nftReceiver; bytes output = Util.buildOutput(outputScript, nftAmount); outputs += output; } if (p2pkhAmount2 > 0) { bytes outputScript = Util.buildPublicKeyHashScript(p2pkhReceiver2); bytes output = Util.buildOutput(outputScript, p2pkhAmount2); outputs += output; } if (p2pkhAmount3 > 0) { bytes outputScript = Util.buildPublicKeyHashScript(p2pkhReceiver3); bytes output = Util.buildOutput(outputScript, p2pkhAmount3); outputs += output; } Sha256 hashOutputs = hash256(outputs); require(hashOutputs == Util.hashOutputs(txPreimage)); require(hash160(senderPubKey) == senderPubkeyHash); require(checkSig(sig, senderPubKey)); require(Tx.checkPreimage(txPreimage)); } }
No. | Activity | P1 | N1 | P2 | P3 |
1 | Transfer | No | Yes | Yes | No |
2 | Listing | Yes (sigtype_single) | Yes | No | Determined by whether it needs change or not |
3 | Listing (with platform commission) | Yes (sigtype_single) | Yes | Yes | Determined by whether it needs change or not |
4 | Destroy | Yes | No | No | Determined by whether it needs change or not |
import "util.scrypt"; contract Nft { public function unlock(Sig sig, PubKey senderPubKey, SigHashPreimage txPreimage, Ripemd160 p2pkhReceiver1, int p2pkhAmount1, Ripemd160 nftReceiver, int nftAmount, Ripemd160 p2pkhReceiver2, int p2pkhAmount2, Ripemd160 p2pkhReceiver3, int p2pkhAmount3) { bytes lockingScript = Util.scriptCode(txPreimage); int scriptLen = len(lockingScript); int pubkeyHashStart = scriptLen - Util.PubKeyHashLen; Ripemd160 senderPubkeyHash = Ripemd160(lockingScript[pubkeyHashStart :]); bytes codePart = lockingScript[: pubkeyHashStart]; bytes outputs = b''; if (p2pkhAmount1 > 0) { bytes outputScript = Util.buildPublicKeyHashScript(p2pkhReceiver1); bytes output = Util.buildOutput(outputScript, p2pkhAmount1); outputs += output; } if (nftAmount > 0) { bytes outputScript = codePart + nftReceiver; bytes output = Util.buildOutput(outputScript, nftAmount); outputs += output; } if (p2pkhAmount2 > 0) { bytes outputScript = Util.buildPublicKeyHashScript(p2pkhReceiver2); bytes output = Util.buildOutput(outputScript, p2pkhAmount2); outputs += output; } if (p2pkhAmount3 > 0) { bytes outputScript = Util.buildPublicKeyHashScript(p2pkhReceiver3); bytes output = Util.buildOutput(outputScript, p2pkhAmount3); outputs += output; } Sha256 hashOutputs = hash256(outputs); require(hashOutputs == Util.hashOutputs(txPreimage)); require(hash160(senderPubKey) == senderPubkeyHash); require(checkSig(sig, senderPubKey)); require(Tx.checkPreimage(txPreimage)); } }
No. | Activity | P1 | N1 | P2 | P3 |
1 | Transfer | No | Yes | Yes | No |
2 | Listing | Yes (sigtype_single) | Yes | No | Determined by whether it needs change or not |
3 | Listing (with platform commission) | Yes (sigtype_single) | Yes | Yes | Determined by whether it needs change or not |
4 | Destroy | Yes | No | No | Determined by whether it needs change or not |