How to Use APIs to Play Ordinals on Bitcoin?
How to Use APIs to Play Ordinals on Bitcoin?
BTC Layer2 is growing up rapidly, there might be more than 100+ BTC L2 launching in this round, side chains, off-chain computing, Rollup, data availability, status channels, client verification and others. They are generated due to the scalability request of Bitcoin network, while this round's scability requests come from the protocol or stories from ordinals from some point of view. So let's have a basic understanding for ordinals before digging into more.
Ordinals, an imaginable idea on Bitcoin to expect artifacts active, permanent and valuable than NFT on EVM, attracted millions of interests over the blockchain world. The intrinsic and distinct rarity of satoshi appeals investors to join and to make profits. Bunch of apps, websites, tools are built to play ordinals, inscribe, transfer and deposited.
Tokenview provides 6 APIs to help builders decorating their popular oridnals apps, to get the inscription detail information, to display the fantastic images,videos, to get the owner's inscription list, to fetch the inscription mint and transfer from the latest blocks. Let's check them one by one.
How to use 6 APIs to get ordinals information?
Query with txid, return inscription details
https://services.tokenview.io/vipapi/ord/tx/{txid}?apikey={apikey}
"inscriprionInfo": {
"genesisHeight": "784858", // The block height in which the inscription is created
"inscriptionId": "153f70fcb169a138ac5ad3ad0af8ea9917b2fd476b83af8b9439bc9dfd839e0bi0",
"outputValue": "331",
"output": "6bd0381de7570573708e281ca99819af8a0507c7806085be1b3ef90ed6c55506:2",
"inscriptionNum": "1068130",
"createdTime": "2023-04-11 02:40:23 UTC",
"contentLink": "/content/153f70fcb169a138ac5ad3ad0af8ea9917b2fd476b83af8b9439bc9dfd839e0bi0",
"location": "6bd0381de7570573708e281ca99819af8a0507c7806085be1b3ef90ed6c55506:2:0",
"contentLength": "342 bytes",
"ownerAddress": "bc1pmp3y938d8panfpwph5uah7gjvha5d62uqh6rj7zuegr47malv45sfl40np",
"genesisTransaction": "153f70fcb169a138ac5ad3ad0af8ea9917b2fd476b83af8b9439bc9dfd839e0b", // The transaction that created inscription
"contentType": "image/png",
"locationHeight": 789790
}
Query with inscription id, return inscription details
https://services.tokenview.io/vipapi/ord/inscription/byid/{inscription_id}?apikey={apikey}
"data": {
"genesisHeight": "784858", // The block height in which the inscription is created
"inscriptionId": "153f70fcb169a138ac5ad3ad0af8ea9917b2fd476b83af8b9439bc9dfd839e0bi0",
"outputValue": "331",
"output": "6bd0381de7570573708e281ca99819af8a0507c7806085be1b3ef90ed6c55506:2",
"inscriptionNum": "1068130",
"createdTime": "2023-04-11 02:40:23 UTC",
"contentLink": "/content/153f70fcb169a138ac5ad3ad0af8ea9917b2fd476b83af8b9439bc9dfd839e0bi0",
"location": "6bd0381de7570573708e281ca99819af8a0507c7806085be1b3ef90ed6c55506:2:0",
"contentLength": "342 bytes",
"ownerAddress": "bc1pmp3y938d8panfpwph5uah7gjvha5d62uqh6rj7zuegr47malv45sfl40np",
"genesisTransaction": "153f70fcb169a138ac5ad3ad0af8ea9917b2fd476b83af8b9439bc9dfd839e0b", // The transaction that created inscription
"contentType": "image/png",
"locationHeight": 789790
}
Query with inscription num, return inscription details
https://services.tokenview.io/vipapi/ord/inscription/bynum/{inscription_number}?apikey={apikey}
"data": {
"genesisHeight": "784858", // The block height in which the inscription is created
"inscriptionId": "153f70fcb169a138ac5ad3ad0af8ea9917b2fd476b83af8b9439bc9dfd839e0bi0",
"outputValue": "331",
"output": "6bd0381de7570573708e281ca99819af8a0507c7806085be1b3ef90ed6c55506:2",
"inscriptionNum": "1068130",
"createdTime": "2023-04-11 02:40:23 UTC",
"contentLink": "/content/153f70fcb169a138ac5ad3ad0af8ea9917b2fd476b83af8b9439bc9dfd839e0bi0",
"location": "6bd0381de7570573708e281ca99819af8a0507c7806085be1b3ef90ed6c55506:2:0",
"contentLength": "342 bytes",
"ownerAddress": "bc1pmp3y938d8panfpwph5uah7gjvha5d62uqh6rj7zuegr47malv45sfl40np",
"genesisTransaction": "153f70fcb169a138ac5ad3ad0af8ea9917b2fd476b83af8b9439bc9dfd839e0b", // The transaction that created inscription
"contentType": "image/png",
"locationHeight": 789790
}
Query with inscription id, return all transactions of inscription
https://services.tokenview.io/vipapi/ord/inscription/txs/{inscription_id}/1/10?apikey={apikey}
"data": [
{
"block": 789790, // block height
"from": "bc1pguj4a4tzq74pnutf5vcd55jj0nlapmrx85ajn7h8vx5q4mruwylswlv50n", // from address
"time": 1684116827, // timestamp
"to": "bc1pmp3y938d8panfpwph5uah7gjvha5d62uqh6rj7zuegr47malv45sfl40np", // to address
"type": "transfer", // transaction type
"txHash": "6bd0381de7570573708e281ca99819af8a0507c7806085be1b3ef90ed6c55506" // transaction hash
},
{
"block": 784858,
"from": "bc1pu2mu6pldn92czpgrfw3crky8f4jc2qeedzfjv2ez9jwqsgnpa2jsllad0t",
"time": 1681180823,
"to": "bc1pguj4a4tzq74pnutf5vcd55jj0nlapmrx85ajn7h8vx5q4mruwylswlv50n",
"type": "created",
"txHash": "153f70fcb169a138ac5ad3ad0af8ea9917b2fd476b83af8b9439bc9dfd839e0b"
}
]
Query with address, returns a list of inscriptions it owns
https://services.tokenview.io/vipapi/ord/address/{address}/1/10?apikey={apikey}
"data": [
{
"genesisHeight": "784919", // The block height in which the inscription is created
"inscriptionId": "ab6881fe414029e73de79fdfbec49c45799322995cb02cf7ecb932f91f3f1c15i0",
"outputValue": "546",
"output": "2ddca85f51707c243a5ed6cd6ff6fdb442d6177ab0c8e523d9fead7c2a50a7a4:2",
"inscriptionNum": "1075664",
"createdTime": "2023-04-11 13:02:11 UTC",
"contentLink": "/content/ab6881fe414029e73de79fdfbec49c45799322995cb02cf7ecb932f91f3f1c15i0",
"location": "2ddca85f51707c243a5ed6cd6ff6fdb442d6177ab0c8e523d9fead7c2a50a7a4:2:0",
"contentLength": "349 bytes",
"ownerAddress": "bc1pmp3y938d8panfpwph5uah7gjvha5d62uqh6rj7zuegr47malv45sfl40np",
"genesisTransaction": "ab6881fe414029e73de79fdfbec49c45799322995cb02cf7ecb932f91f3f1c15", // The transaction that created inscription
"contentType": "image/png",
"locationHeight": 789781
}
]
Get the Mint/Transfer/Deploy list of the specified block height of Ordinals
"data": [
{
"block": 805000, // block height
"txHash": "003f48e21bf933c59405fc83b34644f8045ded2027fd8b80dfde8475b65eaf07", // transaction hash
"input": "2803b57d46c7dd3ba93ba5c7dad621e28927b68ac4ab232b36b4dd6d1843e53e:184",
"output": "003f48e21bf933c59405fc83b34644f8045ded2027fd8b80dfde8475b65eaf07:0",
"satIndex": 0,
"outputAddr": "bc1q44anwwlap82vtw40qyw2e4ct3574jtn6fx3hur",
"outputValue": "294",
"isGenesis": 1, // 1: create, 0: transfer
"inscriptionId": "003f48e21bf933c59405fc83b34644f8045ded2027fd8b80dfde8475b65eaf07i0",
"inputAddr": "bc1pch0nflq06q49uug6qv79349km2j2hl0yfxljh44sc8rgsmyrvnfsle0h6z",
"inscriptionInfo":
{
"genesisHeight": "805000", // The height of the block when creating the inscription
"inscriptionId": "003f48e21bf933c59405fc83b34644f8045ded2027fd8b80dfde8475b65eaf07i0",
"outputValue": "294",
"content": "{\"p\":\"brc-20\",\"op\":\"mint\",\"tick\":\"sats\",\"amt\":\"99999999\"}",
"output": "003f48e21bf933c59405fc83b34644f8045ded2027fd8b80dfde8475b65eaf07:0",
"inscriptionNum": "26769914",
"createdTime": "2023-08-27 03:31:42 UTC",
"contentLink": "/content/003f48e21bf933c59405fc83b34644f8045ded2027fd8b80dfde8475b65eaf07i0",
"location": "003f48e21bf933c59405fc83b34644f8045ded2027fd8b80dfde8475b65eaf07:0:0",
"contentLength": "57 bytes",
"ownerAddress": "bc1q44anwwlap82vtw40qyw2e4ct3574jtn6fx3hur",
"genesisTransaction": "003f48e21bf933c59405fc83b34644f8045ded2027fd8b80dfde8475b65eaf07", // Create transactions for inscription
"contentType": "text/plain"
}
}]
With all of the above, end users will be able to have a clear understanding of their inscriptions and know exactly what are inscribed, what are transferred. Well then, how to make profit? There is last step to deposit them onto exchanges.
How to deposit oridinals to exchanges?
This is the most critical step to make profit. Any inscription you mint on ordinals apps are static, not live on blockchain, not live on exchanges either, there must be a third-party project to recoginize and to lead the price on market. So the last step is to send your static inscriptions into exchanges or somewhere else where parcipants can arrive to join together. Let's see how to send.
In essence, any inscription is an UTXO, you can understand it is an unspent bitcoin in your wallet, now you want to send this UTXO to exchanges or other people. One of the method is to use Tokenview Bitcoin node service:
https://services.tokenview.io/vipapi/nodeservice/btc?apikey={apikey}
- generate a transaction, it would be a transfer containing this UTXO
a. Using createrawtransaction to generate the target UTXO transfercreaterawtransaction [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount,...},{"data":"hex"},...] ( locktime replaceable )
Create a transaction spending the given inputs and creating new outputs.
b. Using signrawtransactionwithkey to sign the transaction with your private keysignrawtransactionwithkey "hexstring" ["privatekey",...] ( [{"txid":"hex","vout":n,"scriptPubKey":"hex","redeemScript":"hex","witnessScript":"hex","amount":amount},...] "sighashtype" )
Sign inputs for raw transaction (serialized, hex-encoded). - broadcast this transaction onto Bitcoin network
a. Using sendrawtransaction to do the broadcastingsendrawtransaction "hexstring" ( maxfeerate )
Submit a raw transaction (serialized, hex-encoded) to network. - wait for the bitcoin miners to package your transaction into block
For the full Bitcoin document, please refer https://services.tokenview.io/docs?type=api&chain=btc.
Conclusion
Ordinals are a creative step for Bitcoin, as it extends the possibilities of Bitcoin. Whereas it may hurt Bitcoin as there are lots of "nonsense" logged on the network, impact the purity of the first blockchain. Anything will be a try before the world stablize at some time period. Step out and try, to be a bright future.
Tokenview is always here, honestly providing the data on blockchains. Welcome for any suggestions and recommendations.