0

Is there a way of defining contract data to be deployed and then running in a batch to deploy to the Blockchain? I am developing an application and would like to have the ability to load up test data in a batch when I change the code in a given function/ contract.

I use remix to deploy contracts although I do deploy some contracts dynamically in JavaScript using Web3 calls.

Any ideas?

1

Remix is good working out syntax and for superficial testing.

Truffle + Ganache is a favorite combination for deeper testing. Although there is extra learning curve involved with another toolset, many developers find it well worth the effort.

Truffle has two approaches that might help:

  1. Scripted (JavaScript) migrations that coordinate deployment and can execute a series of transactions to initialize a system.
  2. Scripted unit testing that can include initializing a system with test data before running a battery of tests.

Ganache is a blockchain emulator similar to Remix's JavaScript VM. These tools work well together.

Hope it helps.

  • Thanks. I am in the process of implementing Truffle! – Philip Rutovitz Jun 30 at 18:31
0

Can you elaborate the scenario "contract data to be deployed" and "deploy to the Blockchain". Question isn't clear.

If you are looking out for batch processing of contract functions then try this.

const contract = new web3.eth.Contract(abi, address);
const batch = new web3.BatchRequest();
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest'));
batch.add(contract.methods.balance(address).call.request({from: '0x0000000000000000000000000000000000000000'}));
batch.execute().then(...);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.