Created
March 17, 2022 17:39
-
-
Save duanescarlett/45decb9fcc38e4edce26c360769060f4 to your computer and use it in GitHub Desktop.
Convert from number to wei
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') | |
require('dotenv').config() | |
const main = async () => { | |
// Connect to an EVM blockchain | |
const web3 = new Web3(Web3.givenProvider || process.env.INFURA_URL) | |
// Convert from a decimal number to a wei number | |
let amt = web3.utils.toWei('0.1', 'ether') | |
console.log(amt) | |
} | |
main() | |
.then(() => process.exit(0)) | |
.catch((err) => { | |
console.error(err) | |
process.exit(1) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment