Created
September 7, 2021 15:20
-
-
Save critesjosh/43c60bc019c672482839d82dcccca37b to your computer and use it in GitHub Desktop.
example tx to send cUSD using cEUR as tx fees.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Web3 = require('web3') | |
const ContractKit = require('@celo/contractkit') | |
const web3 = new Web3(`https://celo-alfajores--rpc.datahub.figment.io/apikey/${process.env.FIGMENT_API_KEY}/`) | |
async function sendCELOTx(){ | |
// Connect to the network and get the current tx count | |
let nonce = await kit.web3.eth.getTransactionCount(kit.defaultAccount) | |
// Send 0.1 CELO | |
let amount = kit.web3.utils.toWei("0.1", "ether") | |
let CeloTx = { | |
to: "0x9a8e698171364db8e0F5Fe30f658F233F1347F6a", // omit recipient for a contract deployment | |
from: account.address, | |
gas: 200000, // surplus gas will be returned to the sender | |
nonce: nonce, | |
chainId: "44787", // Alfajores chainId | |
data: "0x0", // data to send for smart contract execution | |
value: amount, | |
// The following fields can be omitted and will be filled by ContractKit, if required | |
// gasPrice: "", | |
gatewayFee: 0, | |
gatewayFeeRecipient: "", | |
feeCurrency: "" // optionally set feeCurrency, ie "0x10c892A6EC43a53E45D0B916B4b7D383B1b78C0F" | |
} | |
let stabletoken = await kit.contracts.getStableToken() | |
await kit.setFeeCurrency(ContractKit.CeloContract.StableTokenEUR) | |
let tx = await stabletoken.transfer("0x9a8e698171364db8e0F5Fe30f658F233F1347F6a", amount).send({ from: account.address }) | |
let receipt = await tx.waitReceipt() | |
console.log(`CELO tx: https://alfajores-blockscout.celo-testnet.org/tx/${receipt.transactionHash}/token-transfers `) | |
} | |
sendCELOTx() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment