I am new to smart contracts, web3. I am trying to deploy a smart contract to ganache-cli and store the blockchain in a database. When I run the below code I am able to deploy the contract but unable to create the database and store blockchain. I am getting no errors. Any help is much appreciated.

Here is the deploy code

const ganache = require('ganache-cli');
const { Web3 } = require('web3');
const {abi, evm} = require('./compile');

const options = { database: {db_path: 'my/path/to/db'} };

const web3 = new Web3(ganache.provider(options));
const deploy = async () => {
const accounts = await web3.eth.getAccounts();
console.log('Attempting to deploy from account', accounts[0]);
const result = await new web3.eth.Contract(abi)
.deploy({data: evm.bytecode.object})
.send({ from: accounts[0], gas: 5000000 });
console.log("Contract deployed to", result.options.address);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.