1

My goal is to sign a raw transaction, then broadcast it through the Ftmscan/Etherscan API. I don't want to deal with web3 providers like Infura/Alchemy, if possible. Just write the raw transaction, then FTMScan API will broadcast.

I understood how to create and sign a simple transaction with Node and the Ethers.js library :

const ethers = require('ethers');

async function main() {

// defining the wallet private key let privatekey = 'my_wallet_private_key'; let wallet = new ethers.Wallet(privatekey);

// print the wallet address console.log('Using wallet address ' + wallet.address);

let transaction = { to: 'my_wallet_adress', value: ethers.utils.parseEther('0'), gasLimit: '200000', maxPriorityFeePerGas: ethers.utils.parseUnits('100', 'gwei'), maxFeePerGas: ethers.utils.parseUnits('115', 'gwei'), nonce: 0, type: 2, chainId: 250 };

// sign and serialize the transaction let rawTransaction = await wallet.signTransaction(transaction).then(ethers.utils.serializeTransaction(transaction));

// print the raw transaction hash console.log('Raw txhash string ' + rawTransaction);

}

main();

Ok, not difficult. And it works when I broadcast it with the FTMScan API.

But I don't understand how to interact with an already existing contract.

For exemple, let's take the "mint" function (= deposit on lending pool) on Impermax (https://fantom.impermax.finance) : Contract : https://ftmscan.com/address/0xb9f3413e206f1d658d4dafb233873dde56cf94fc#code

When I execute a deposit from the UI, and from what I can read in Ftmscan, I can see this function is waiting for 4 parameters :

function mint(address poolToken, uint amount, address to, uint deadline) external returns (uint tokens);

How can I insert this function call with parameters in the above transaction ? Is it possible this way actualy ?

Ico
  • 11
  • 2

0 Answers0