Search…
⌃K

Bitcoin

Bitcoin Transfers

BitcoinTransfers Stream represents all possible native cryptocurrency transfers with positive (> 0) value

Details

{
address: address'btc',
currency: string,
amount: integer,
tx: {
id: string,
blockHash: string,
blockHeight: integer,
blocktime: integer,
confirmations: integer,
inputs: {
value: {
txId: string,
amount: integer,
n: integer,
addresses: list {
value: address'btc'
}
}
},
outputs: {
value: {
txId: string,
amount: integer,
n: integer,
addresses: list {
value: address'btc'
}
}
}
},
type: string
}

Code Samples

This simple code will monitor every transfer on 1 address
stream BalanceChanges
from BitcoinTransfers
where @address == BTC.address("address")
process
emit { @address, @type, @amount }
end
If you want to distinguish between transactions that are in mempool and in block (confirmed):
If you set @tx.confirmations to 2 or above, it will not work. Our platform can only see the first confirmation of a transaction
stream BitcoinMonitoring
from BitcoinTransfers
where @address == BTC.address("address")
process
if @tx.confirmations >= 1 then
emit {@type, @amount, @address, state: "in block"}
else
emit {@type, @amount, @address, state: "in mempool"}
end
end
If you want to add current price of BTC, you need to use getRate function
stream BitcoinMonitoring
from BitcoinTransfers
where @address == BTC.address("address")
process
let currentPrice = getRate("BTC")
if @tx.confirmations >= 1 then
emit {@type, @amount, @address, state: "in block", currentPrice}
else
emit {@type, @amount, @address, state: "in mempool", currentPrice}
end
end
Last modified 1yr ago