Prepare some utxos to use in the following format. Be sure to use base64 encoded scripts. We use this encoding because it makes large scripts smaller in size.
You can use the helper fetchPayUtxos(address) to fetch unspent transaction outputs from the public 1Sat API and create the scripts with the correct encoding (base64). This should be a BSV address, not your ordinals address. Note: By default the script encoding will be base64, but you can provide a 2nd parameter and specify hex or asm encoding for the script property.
Note: Utxo and NftUtxo and TokenUtxo have an optional pk field for specifying a Private Key for unlocking this utxo. This is helpful when multiple keys own the inputs and you need to spend them in a single transaction.
For NFTUtxos:
For Token Utxos:
Prepare Inscription
For a markdown inscription, you can create a string and convert it to base64:
Prepare Keys
Be sure to use different keys for ordinals and normal payments:
Create Ordinals
The createOrdinals function creates a transaction with inscription outputs:
Send Ordinals
Sends ordinals to the given destinations:
Deploy a BSV21 Token
Transfer BSV21 Tokens
Note: To burn tokens you can set the optional burn parameter to true Note: You can use the optional splitConfig parameter to configure how and when to split token change outputs, and whether change outputs should include metadata. Note: You can use the optional tokenInputMode parameter to configure whether all tokens are consumed, or only what's needed. Default is needed.
Send Utxos
Sends utxos to the given destination:
Create Ordinal Listings
Creates a listing using an "Ordinal Lock" script. Can be purchased by anyone by sending a specific amount to the provided address.
Purchase Ordinal Listing
Cancel Ordinal Listings
Spends the ordinal lock without payment, returning the ordinal to the address specified in the listing contract.
Additional Configuration Options
Each function accepts additional configuration options not shown in the examples above. These may include:
changeAddress: Address to send change to (if not provided, defaults to the payment key's address)
satsPerKb: Satoshis per kilobyte for fee calculation
metaData: MAP (Magic Attribute Protocol) metadata to include in inscriptions
signer: LocalSigner or RemoteSigner object for adding Sigma protocol signatures to transactions (provides replay protection)
additionalPayments: Additional payments to include in the transaction
Using Sigma Protocol Signatures
Several functions support optional Sigma protocol signatures for replay protection: