I'm developing a performance test where I check the time a gateway spends to find a contract in a blockchain. I'm using ganache-cli to simulate the blockchain, my doubts are:

1) Is it possible to generate 100 contracts at one time using the truffle? Should each of these contracts have a different name or can all have the same name?

2) When I use the truffle migrate command I can get the addresses of each contract in the terminal that is running ganache. How do I use web3js to get the contract that I know the addresses?


On blockchain there is no such thing as contract name. Deployed contract has only address, balance, nonce, byte code, and storage.

You may create many contracts in one transaction like this:

contract Foo {
  // Some stuff to be deployed multiple times

contract Bar {
  event FooAddress (address indexed addr);

  // Deploy n instances of Foo contract and then self destruct
  constructor (uint256 n) public {
    while (n --> 0) {
      emit FooAddress (address (new Foo ()));
    selfdestruct (msg.sender);

You may get addresses of deployed contracts by querying FooAddress events from Bar contract.

  • Thanks for the answer! I'm using ganache, so is returned the contract address everytime a contract is mined. So my doubt is: How can I retrieve a contract status using the address that i know? – Mutante Apr 20 at 19:17
  • Basically what I want to know is: If I know the transaction address, no matter how many blocks the blockchain has, The time to change the status of a contract will be the same if the blockchain has only 10 blocks or 1 block... – Mutante Apr 20 at 19:50
  • What do you mean by contract status? – Mikhail Vladimirov Apr 20 at 19:58
  • perform a getFunction() from a contract. – Mutante Apr 21 at 22:49

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.