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
ethers = require('ethers') | |
require('dotenv').config() | |
async function main () { | |
// Connect to an EVM network | |
const provider = new ethers.providers.JsonRpcProvider(`https://polygon-mainnet.g.alchemy.com/v2/${process.env.RPC_KEY}`) | |
// Get the gas price | |
const gasPrice = provider.getGasPrice() | |
// Create a wallet object from private key | |
const wallet = new ethers.Wallet(`${process.env.PRIVATE_KEY}`) |
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
ethers = require('ethers') | |
require('dotenv').config() | |
const main = async () => { | |
// Create a wallet | |
const wallet = ethers.Wallet.createRandom() | |
console.log('Address: ', wallet.address) // Wallet Address | |
console.log('Mnemonic: ', wallet.mnemonic.phrase) // Wallet Mnemonic Phrase | |
console.log('Private Key: ', wallet.privateKey) // Wallet Private Key |
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
ethers = require('ethers') | |
require('dotenv').config() | |
const main = async () => { | |
// Import a wallet | |
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY) | |
console.log('Address: ', wallet.address) // Wallet Address | |
console.log('Private Key: ', wallet.privateKey) // Wallet Private Key |
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
ethers = require('ethers') | |
require('dotenv').config() | |
const main = async () => { | |
// Import a wallet | |
const wallet = new ethers.Wallet.fromMnemonic(process.env.MNEMONIC) | |
console.log('Address: ', wallet.address) // Wallet Address | |
console.log('Private Key: ', wallet.privateKey) // Wallet Private Key |
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) |
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 ethers = require('ethers') | |
const { toChecksumAddress } = require('ethereum-checksum-address') | |
require('dotenv').config() | |
const main = async () => { | |
// Connect to an EVM network | |
const provider = new ethers.providers.JsonRpcProvider(`https://polygon-mainnet.g.alchemy.com/v2/${process.env.RPC_KEY}`) | |
// Create a wallet | |
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY) | |
// Get a signer |
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 a 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('Convert from a decimal number to a wei number', amt) |
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 ethers = require('ethers') | |
const { toChecksumAddress } = require('ethereum-checksum-address') | |
require('dotenv').config() | |
const main = async () => { | |
// Connect to an EVM network | |
const provider = new ethers.providers.JsonRpcProvider(`https://polygon-mainnet.g.alchemy.com/v2/${process.env.RPC_KEY}`) | |
// Create a wallet | |
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY) | |
// Get a signer |
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 ethers = require('ethers') | |
const { toChecksumAddress } = require('ethereum-checksum-address') | |
require('dotenv').config() | |
const main = async () => { | |
// Connect to an EVM network | |
const provider = new ethers.providers.JsonRpcProvider(`https://rpc.ankr.com/bsc`) | |
// Create a Factory contract abi | |
const IPair = [ |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.17; | |
contract VariablesAndDataTypes { | |
// State Variables | |
int256 public oneIng = 1; | |
uint256 public oneUint = 1; | |
// Local Variable | |
function getValue() public pure returns(uint256) { |
OlderNewer