Chained APIs - Chinese
使用链式 APIs
部署
async function deployContract(contract, amount) {
const address = privateKey.toAddress()
const tx = new bsv.Transaction()
tx.from(await fetchUtxos(address)) // 添加用来支付矿工费用和锁进合约的比特币的UTXO。钱包通常会在这里做 UTXO 的筛选,以防止添加过多 UTXO
.addOutput(new bsv.Transaction.Output({
script: contract.lockingScript, // 将合约部署到第0个输出的锁定脚本
satoshis: amount,
}))
.change(address) // 添加找零输出
.sign(privateKey) // 私钥签名, 只对P2PKH输入有效
await sendTx(tx) // 广播交易
return tx
}
调用合约
不包含 SigHashPreimage
SigHashPreimage包含 SigHashPreimage
SigHashPreimage扩展的 APIs 列表
Api
描述
参数
Last updated