blocklate-sdk
v1.0.5
Published
A Blockchain transaction simulator
Downloads
3
Readme
Blocklate SDK
A javascript sdk to simulate blockchain transactions.
to use our sdk, you must setup a hardhat environment first.
setting up a hardhat run:
npm install --save-dev hardhat
// Create an empty hardhat.config.js, by running:
npx hardhat
this will create an hardhat config file like this
require("@nomicfoundation/hardhat-toolbox");
module.exports = {
solidity: '0.8.1'
};
then install our SDK:
npm install blocklate-sdk
After installing the SDK, you can use the following snippet to test the SDK
const {BlockLateSdk} = require('blocklate-sdk')
const s = new BlockLateSdk('<ALCHEMY_KEY>')
// replace <ALCHEMY_KEY> with your own key
s.simulateTransaction({
network: 'ethereum',
tokenContractAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
userAddress: '0x616efd3e811163f8fc180611508d72d842ea7d07',
data: '0xa9059cbb0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000016444b4c0f706f14e'
}).then(res => console.log(res)).catch(err => console.log(err))
Or you can make multiple Simulations with this snippet
s.simulateTransactions([
{
network: 'polygon',
tokenContractAddress: '0x82a0E6c02b91eC9f6ff943C0A933c03dBaa19689',
userAddress: '0xD1A37044F3Fd2AbA5355788661Cf6c7e7025E8B0',
data: '0x095ea7b30000000000000000000000000d2dd4f745a6fe105932825fa084b7aa6b582a1000000000000000000000000000000000000000000000010f0cf064dd59200000'
},
{
network: 'ethereum',
tokenContractAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
userAddress: '0x616efd3e811163f8fc180611508d72d842ea7d07',
data: '0xa9059cbb0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000016444b4c0f706f14e'
},
]).then(res => {
for (let t of res){
console.log(t)
}
}).catch(err => console.log(err))