Skip to content

Instantly share code, notes, and snippets.

Last active Nov 4, 2020
What would you like to do?
Node js script for Deployment to Moonbase testnet.
const Web3 = require('web3');
const { bytecode, abi } = require('./truffle/build/contracts/<CONTRACT_NAME>.json');
// Initialization
const web3 = new Web3('');
const walletPrivateKey = <PRIVATE_KEY>;
const walletAddress = <WALLET_ADDRESS>;
// Deploy contract
const deploy = async () => {
console.log('⏳ Attempting to deploy from account:', walletAddress);
const contract = new web3.eth.Contract(abi);
const contractTx = contract.deploy({
data: bytecode,
// arguments: [], // if constructor needs arguments put it in array here like this [5, '0x...', 'Hello World']
const createTransaction = await web3.eth.accounts.signTransaction(
from: walletAddress,
data: contractTx.encodeABI(),
gas: '4294967295',
const createReceipt = await web3.eth.sendSignedTransaction(
);`- Amount of Gas Used: ${createReceipt.gasUsed}`);`- More transaction details at:${createReceipt.transactionHash}`);
console.log('✅ Contract deployed at address', createReceipt.contractAddress);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment