Chained APIs
Using Chained APIs
Deploy Contract
async function deployContract(contract, amount) {
const address = privateKey.toAddress()
const tx = new bsv.Transaction()
tx.from(await fetchUtxos(address)) // Add UTXOs/bitcoins that are locked into the contract and pay for miner fees. In practice, wallets only add enough UTXOs, not all UTXOs as done here for ease of exposition.
.addOutput(new bsv.Transaction.Output({
script: contract.lockingScript, // Deploy the contract to the 0-th output
satoshis: amount,
}))
.change(address) // Add change output
.sign(privateKey) // Sign inputs. Only apply to P2PKH inputs.
await sendTx(tx) // Broadcast transaction
return tx
}
Call contract
No SigHashPreimage
SigHashPreimageSigHashPreimage
SigHashPreimageExtended APIs list
Api
description
parameters
Last updated