Overview
Blockchain transactions are encrypted into hashes and it's not possible to simply understand for someone who doesn't know a lot about cryptography or blockchain technology that what's going on in that transaction. Noves Translate API is a powerful tool that helps you decode a transaction and make it easier to understand.
In this Function example, we will create a multi-chain transaction translator, using Noves Translate API.
Sample Function
The first step here would be to get a Noves API key.
Then Head over to the QuickNode Functions editor and paste the following code in it:
function main(params) {
// Extract necessary information from params
const vm = params.user_data.vm;
const chain = params.user_data.chain;
const txhash = params.user_data.txhash;
const apiKey = params.user_data.apiKey;
// Construct the URL
const url = `https://translate.noves.fi/${vm}/${chain}/tx/${txhash}`;
// Set up the options for the fetch request
const options = {
method: 'GET',
headers: {
'accept': 'application/json',
'apiKey': apiKey
}
};
// Perform the fetch request and return the data as-is
return fetch(url, options)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
// Simply return the data without any processing
console.log(data); // This will print the data in the QuickNode logs
return data;
})
.catch(error => {
console.error('Error:', error);
return {
error: error.message
};
});
}
In the above code we're getting few things like the vm (virtual machine), chain, transaction hash, and API key from user and sending request to the Noves API and printing the response along with some error handling.
Request
We will send our request with few parameters like vm (virtual machine), chain, transaction hash, and API key.
- vm can be
evm
for EVM (Ethereum Virtual Machine) blockchains,svm
for SVM (Solana Virtual Machine) used by Solana, andcosmos
for Cosmos blockchains. - chain can be the following based on the virtual machine/ecosystem:
- evm (
arbitrum
,arbitrum-nova
,astar
,avalanche
,base
,berachain-bartio
,blast
,bsc
,camp-testnet
,camp-testnet-v2
,celo
,chiliz
,core
,cronos
,degen
,eth
,eth-holesky
,eth-sepolia
,ethxy-testnet
,fantom
,flow-evm
,fraxtal
,fuse
,gnosis
,kava-evm
,lightlink
,linea
,lukso
,manta-pacific
,mantle
,matchain
,metis
,moonbeam
,moonriver
,morph-holesky-testnet
,morph-testnet
,movement-mevm
,optimism
,orderly-network
,plume-testnet
,polygon
,polygon-zkevm
,pulsechain
,rari
,rollux
,rollux-testnet
,scroll
,sophon-testnet
,superposition-testnet
,superseed-sepolia
,taiko-katla
,telos
,xai
,xdc
,zetachain-evm
,zetachain-evm-testnet
,zksync-era
,zora
). - svm (
solana
). - cosmos (
celestia
,dymension
).
- evm (
txhash
will be your transaction hash for that particular chain.apiKey
will be your Noves API Key.
We will invoke the function with the following cURL command. Be sure to also replace the YOUR_API_KEY with your own QuickNode API key and the POST URL with the URL of your Function along with the params mentioned above.
curl -X POST "https://api.quicknode.com/functions/rest/v1/functions/{functionId}/call?result_only=true" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"user_data": {
"vm":"evm",
"txhash":"0x1cd4d61b9750632da36980329c240a5d2d2219a8cb3daaaebfaed4ae7b4efa22",
"apiKey":"NOVES_API_KEY",
"chain":"eth"
}
}'
Response
Resulting in the following response:
{
"accountAddress" : "0xA1EFa0adEcB7f5691605899d13285928AE025844",
"chain" : "eth",
"classificationData" : {
"description" : "Added 22,447.92 YD-ETH-MAR21 and 24,875.82 USDC to a liquidity pool.",
"protocol" : {
"name" : null
},
"received" : [
{
"action" : "refundedByContract",
"amount" : "224.479236968293741306",
"from" : {
"address" : "0xaD270aDA5Ce83C6B87976E33D829763f03fD59f1",
"name" : "DSProxy"
},
"to" : {
"address" : "0xA1EFa0adEcB7f5691605899d13285928AE025844",
"name" : "@kaijuking779: kaijuking779.eth"
},
"token" : {
"address" : "0x90f802c7e8fb5d40b0de583e34c065a3bd2020d8",
"decimals" : 18,
"name" : "Yield Dollar [WETH Mar 2021]",
"symbol" : "YD-ETH-MAR21"
}
},
{
"action" : "lpTokensMinted",
"amount" : "470.185549637132154044",
"from" : {
"address" : "0xaD270aDA5Ce83C6B87976E33D829763f03fD59f1",
"name" : "DSProxy"
},
"to" : {
"address" : "0xA1EFa0adEcB7f5691605899d13285928AE025844",
"name" : "@kaijuking779: kaijuking779.eth"
},
"token" : {
"address" : "0x5e065d534d1daaf9e6222afa1d09e7dac6cbd0f7",
"decimals" : 18,
"name" : "Balancer Pool Token",
"symbol" : "BPT"
}
}
],
"sent" : [
{
"action" : "liquidityAdded",
"amount" : "22447.923696829373668181",
"from" : {
"address" : "0xA1EFa0adEcB7f5691605899d13285928AE025844",
"name" : "@kaijuking779: kaijuking779.eth"
},
"to" : {
"address" : "0xaD270aDA5Ce83C6B87976E33D829763f03fD59f1",
"name" : "DSProxy"
},
"token" : {
"address" : "0x90f802c7e8fb5d40b0de583e34c065a3bd2020d8",
"decimals" : 18,
"name" : "Yield Dollar [WETH Mar 2021]",
"symbol" : "YD-ETH-MAR21"
}
},
{
"action" : "liquidityAdded",
"amount" : "24875.82",
"from" : {
"address" : "0xA1EFa0adEcB7f5691605899d13285928AE025844",
"name" : "@kaijuking779: kaijuking779.eth"
},
"to" : {
"address" : "0xaD270aDA5Ce83C6B87976E33D829763f03fD59f1",
"name" : "DSProxy"
},
"token" : {
"address" : "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"decimals" : 6,
"name" : "USD Coin",
"symbol" : "USDC"
}
},
{
"action" : "paidGas",
"amount" : "0.010437901",
"from" : {
"address" : "0xA1EFa0adEcB7f5691605899d13285928AE025844",
"name" : "This wallet"
},
"to" : {
"address" : null,
"name" : null
},
"token" : {
"address" : "ETH",
"decimals" : 18,
"name" : "ETH",
"symbol" : "ETH"
}
}
],
"source" : {
"type" : "human"
},
"type" : "addLiquidity"
},
"rawTransactionData" : {
"blockNumber" : 12345453,
"fromAddress" : "0xA1EFa0adEcB7f5691605899d13285928AE025844",
"gas" : 378651,
"gasPrice" : 47000000000,
"gasUsed" : 222083,
"timestamp" : 1619833950,
"toAddress" : "0xaD270aDA5Ce83C6B87976E33D829763f03fD59f1",
"transactionFee" : {
"amount" : "0.010437901",
"token" : {
"address" : "ETH",
"decimals" : 18,
"name" : "ETH",
"symbol" : "ETH"
}
},
"transactionHash" : "0x1cd4d61b9750632da36980329c240a5d2d2219a8cb3daaaebfaed4ae7b4efa22"
},
"txTypeVersion" : 2
}
Learn more about QuickNode Functions.
We ❤️ Feedback!
Let us know if you have any feedback or requests for new topics. We'd love to hear from you.