It would be good to know how many times a transaction has been confirmed on the RSK blockchain so that when one user sends RIF to another wallet or to an exchange wallet for example we can see how many confirmations have occurred
Generally, a transaction is considered a success (or completed) after six block confirmations.
Related Content. Also known as a trade confirmation, or simply, a confirmation (or "confirm"). A document which parties to a swap or other derivatives transaction use to specify the commercial terms of the transaction, including pricing terms such as the transaction's spread.
The RSK platform is a language based protocol Solidity it works like a side chain running in parallel to the Bitcoin blockchain. This protocol is based on a bidirectional communication that operates as a bridge to connect both chains. In this way, it allows the Bitcoin network to assist RSK in its execution.
RSK also allows decentralized finance application developers to create their DeFi protocols, NFTs, or other digital assets using the Bitcoin blockchain.
The number of transactions per second executable on the RSK platform is determined by the block gas limit and the average block rate. The current average block rate is one block every 30 seconds. At each mined block, the miner can vote to increase the block gas limit. Currently the block gas limit is 6. 8M gas units per block.
The RSK blockchain is secured by merge-mining, with some additional security measures. The RSK blockchain is mined by the Bitcoin miners, which are part of the largest and most reliable blockchain network in the world. Currently, more than 35% percent of the Bitcoin hash rate is simultaneously merge-mining RSK.
A recent paper established that in the context of transaction reversal probability, 6 Bitcoin confirmations (average 1 hour) would be equivalent to approximately 12 RSK confirmations (average 6 minutes). While Bitcoin has the concept of 0-confirmations (the transaction has been broadcast without Replace-by-fee), there is no similar concept in RSK.
An RSK address is an identifier of 40 hexadecimal characters while the Bitcoin address is an identifier of 26-35 alphanumeric characters. For use cases informations, see Use Cases. How does RSK compare with similar bitcoin sidechain projects?
Transactions do not have a confirmation count per se, but the blocks that they are a part of do indeed have confirmation counts. Thus, the solution lies in "comparing" the block number of a particular transaction.
There are several ways to do this,
and the easiest method is the eth_getTransactionByHash
JSON-RPC method:
curl \
-X POST \
-H "Content-Type:application/json" \
--data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xf1ebb8076ad289fbaef4406bb0488be0c5605a58cfa2a6d11540b1f9b0d7ef98"],"id":1}' \
https://public-node.testnet.rsk.co
The above cURL command is for transaction 0xf1ebb8076ad289fbaef4406bb0488be0c5605a58cfa2a6d11540b1f9b0d7ef98
on the RSK Testnet.
The response is copied below:
{
"result" : {
"input" : "0xcbf8...(redacted)",
"nonce" : "0xda62",
"blockNumber" : "0x17fe5c",
"gasPrice" : "0x3938700",
"hash" : "0xf1ebb8076ad289fbaef4406bb0488be0c5605a58cfa2a6d11540b1f9b0d7ef98",
"blockHash" : "0xede9aa2ff4939482186d4e6bd269582352a923db13ef90ad7def0d0dec17a239",
"r" : "0x8c98a16250d157db1fb11e1304684943796710e3f1292a4fb60a0711692f2b8f",
"value" : "0x0",
"s" : "0x49cdc35f66dbea2ba88e3c52dc3f4c68498b844dd79eebafc326803e7163f7fc",
"transactionIndex" : "0x0",
"gas" : "0x17c65",
"from" : "0xd761cc1ceb991631d431f6dde54f07828f2e61d2",
"to" : "0x8bf2f24afbb9dbe4f2a54fd72748fc797bb91f81",
"v" : "0x1c"
},
"jsonrpc" : "2.0",
"id" : 1
}
From "blockNumber" : "0x17fe5c"
we know that the block number of this particular block is 1572444
.
The next step is to compare this block number of this transaction to the latest block number. To do so, we need to use a different JSON-RPC request.
curl \
-X POST \
-H "Content-Type:application/json" \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
https://public-node.testnet.rsk.co
{
"id" : 1,
"result" : "0x180208",
"jsonrpc" : "2.0"
}
From "result" : "0x180208"
we know that the block number of the most recent block is 1573384
.
node -e "console.log(0x180208 - 0x17fe5c);"
940
We subtract the transaction's block number
from the latest block number,
which yields the answer:
940
in this case - the number of confirmations.
You can do the same using web3 (different hash in the example, mainnet):
web3.eth.getTransaction("0x9117f2fab63c89676b6538a317d0b9ec74cc4ac8f375c80c0f2b57223cbd6bb2")
{ hash: '0x9117f2fab63c89676b6538a317d0b9ec74cc4ac8f375c80c0f2b57223cbd6bb2',
nonce: 118329,
blockHash: '0x02c40394a7ed66bc50a0f1853220a395efd1e3cfebea5e0ff36dd5a0a12b2aeb',
blockNumber: 3089723,
transactionIndex: 1,
from: '0x64DCC3BCbeaE8ce586CaBDef79104986bEAFcaD6',
to: '0xBEd51D83CC4676660e3fc3819dfAD8238549B975',
gas: 2000000,
gasPrice: '60000000',
value: '0',
input: '0x5a686699000000000000000000000000000000000000000000000000032d5284006bf8730000000000000000000000000000000000000000000000000000000060214e2a000000000000000000000000504efcadfb020d6bbaec8a5c5bb21453719d0e00',
v: '0x1b',
r: '0x2faaa315b1b3cd7421db1dc5fa243ddfae906282872c2bd9207e7e2dfed8286e',
s: '0x571fa5a28a48755bdf93aacd28d8d7d8986b1e2db0f5450e2355e7f3c91db30b' }
In this case, you get 3089723
from blockNumber
Now, you query the current best block:
web3.eth.getBlockNumber(console.log)
3089747
And, therefore, you have 3089747 - 3089723 = 24
confirmations.
You can also do it with web3.js. As function
const getTxConfirmations = (txHash) => Promise.all([
web3.eth.getTransaction(txHash).then(tx => tx.blockNumber),
web3.eth.getBlockNumber()
]).then(([blockNumber, currentBlockNumber]) => (currentBlockNumber - blockNumber))
And with Truffle console:
truffle(develop)> web3.eth.getTransaction('0x7a28a121c41085ef52d449f64120dbc422ec70b4d324c076c8d89222cf7188c8').then(tx => tx.blockNumber)
1
truffle(develop)> web3.eth.getBlockNumber()
5
truffle(develop)> const getTxConfirmations = (txHash) => Promise.all([web3.eth.getTransaction(txHash).then(tx => tx.blockNumber), web3.eth.getBlockNumber()]).then(([blockNumber, currentBlockNumber]) => (currentBlockNumber - blockNumber))
undefined
truffle(develop)> getTxConfirmations('0x7a28a121c41085ef52d449f64120dbc422ec70b4d324c076c8d89222cf7188c8')
4
I am not sure if my response will be the best, but this is an option do find it.
I usually search in the explorer.rsk.co
I hope it is useful to you :)
You can do the same using web3 (different hash in the example, mainnet):
web3.eth.getTransaction("0x9117f2fab63c89676b6538a317d0b9ec74cc4ac8f375c80c0f2b57223cbd6bb2")
{ hash: '0x9117f2fab63c89676b6538a317d0b9ec74cc4ac8f375c80c0f2b57223cbd6bb2',
nonce: 118329,
blockHash: '0x02c40394a7ed66bc50a0f1853220a395efd1e3cfebea5e0ff36dd5a0a12b2aeb',
blockNumber: 3089723,
transactionIndex: 1,
from: '0x64DCC3BCbeaE8ce586CaBDef79104986bEAFcaD6',
to: '0xBEd51D83CC4676660e3fc3819dfAD8238549B975',
gas: 2000000,
gasPrice: '60000000',
value: '0',
input: '0x5a686699000000000000000000000000000000000000000000000000032d5284006bf8730000000000000000000000000000000000000000000000000000000060214e2a000000000000000000000000504efcadfb020d6bbaec8a5c5bb21453719d0e00',
v: '0x1b',
r: '0x2faaa315b1b3cd7421db1dc5fa243ddfae906282872c2bd9207e7e2dfed8286e',
s: '0x571fa5a28a48755bdf93aacd28d8d7d8986b1e2db0f5450e2355e7f3c91db30b' }
In this case, you get 3089723
from blockNumber
Now, you query the current best block:
web3.eth.getBlockNumber(console.log)
3089747
And, therefore, you have 3089747 - 3089723 = 24
confirmations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With