Withdraw Ordinal Inscriptions
Mint and send ordinal inscriptions using Bitcoin hot wallets. See the Guide.
-
Use the BitGo SDK to mint an ordinal inscription on a Bitcoin hot wallet. This function prepares the reveal transaction with your inscription data and content type, calculates fees, builds a commit transaction to fund the reveal, then signs and sends the reveal transaction.
Ordinal inscriptions are the Bitcoin equivalent of non-fungible tokens (NFTs). Supported content types include image formats (PNG, JPEG, GIF, WebP), audio (MP3, WAV, FLAC), video (MP4, WebM), and text formats (plain text, HTML, JSON, YAML).
Prerequisites: You must have completed the Get Started guide and created a wallet.
-
Use the BitGo SDK to transfer an ordinal inscription to a recipient address. This function prepares the transfer using the
satpoint(the specific location of the inscribed satoshi) and signs and sends the transaction. TheinscriptionConstraintsparameter sets the minimum output value for the inscription.The
satPointidentifies the specific UTXO and offset where the inscription lives, in the formattxid:vout:offset.
// 1. Mint Inscription
// Use the JavaScript SDK for this step (see JavaScript tab)
// 2. Send Transaction
// Use the JavaScript SDK for this step (see JavaScript tab)
// 1. Mint Inscription
async function mintBitcoinInscription(walletId) {
const coin = 'btc';
const walletInstance = await bitgo.coin(coin).wallets().get({ id: walletId });
const inscriptionBuilder = bitgo.coin(coin).getInscriptionBuilder(walletInstance);
const inscriptionData = Buffer.from('BitGoNFT', 'ascii');
const { address, tapLeafScript, revealTransactionVSize } =
await inscriptionBuilder.prepareReveal(inscriptionData, 'text/plain');
// Calculate Fees
const feeRateSatPerKb = 20001;
const sendAmount = new BigNumber( (revealTransactionVSize / 1000) * feeRateSatPerKb).plus(10000);
// Build a commit transaction to pay reveal transaction fees.
const builtTxn = await walletInstance.prebuildTransaction({
recipients: [{
amount: sendAmount.decimalPlaces(0,6).toString(),
address: address,
}],
});
const unsignedCommitTx = builtTxn.txHex;
const unspents = builtTxn.txInfo.unspents;
const recipientAddress = '3LXYcBoqxVcdAFgtRrNoRUjzArxtFjuPuT'
await inscriptionBuilder.signAndSendReveal('walletPassphrase',
tapLeafScript,
address,
Buffer.from(unsignedCommitTx, 'hex'),
unspents,
recipientAddress,
inscriptionData);
}
// 2. Send Transaction
async function sendInscription(walletId) {
const coin = 'btc';
const walletInstance = await bitgo.coin(coin).wallets().get({ id: walletId });
const inscriptionBuilder = bitgo.coin(coin).getInscriptionBuilder(walletInstance);
const feeRateSatKb = 1001;
const satPoint = '41eb6bb6aa7a3cf71d1ccc4429e33efcd76b9c661c014c7c943f7a81f9461e06:0:0';
const recipient = '2MuQkZo9E3M8ryqwxPyrS2QK9yi5TtwKyog';
const buildResult = await inscriptionBuilder.prepareTransfer(
satPoint,
recipient,
feeRateSatKb,
{ inscriptionConstraints: {
minInscriptionOutput: BigInt(5_000),
},
});
await inscriptionBuilder.signAndSendTransfer('walletPassphrase', buildResult);
}