0

Hey I have written a factory for the ERC1400 Token by https://github.com/ConsenSys/ERC1400. When I run the test for issueByPartition I get a revert Error. Other tests like isIssuable works. If I deploy the contract without the factory the customized issueByPartition test passed. Why is my factory deployed contract not working?

ERC1400Factory.sol

pragma solidity ^0.5.0;

import "../../ERC1400.sol";

contract ERC1400Factory {

    ERC1400[] public deployedERC1400;
    bytes32[] public tokenDefaultPartitions;

    address public certificateSigner;

    constructor(address certificat, bytes32[] memory tokenDefaul) public {

    certificateSigner = certificat;
    tokenDefaultPartitions = tokenDefaul;
    }

    function createERC1400(string memory name, string memory symbol, uint256 granularity, address[] memory controllers) public  {

        ERC1400 newERC1400 = new ERC1400(name, symbol, granularity, controllers, certificateSigner, tokenDefaultPartitions);

        deployedERC1400.push(newERC1400);
    }

    function getDeployedERC1400() public view returns (ERC1400[] memory ) {
        return deployedERC1400;
    }
}

ERC1400Factory.test.js

const ERC1400Factory = artifacts.require('ERC1400Factory');
const ERC1400 = artifacts.require('ERC1400');

const CERTIFICATE_SIGNER = '0xe31C41f0f70C5ff39f73B4B94bcCD767b3071630';
const VALID_CERTIFICATE = '0x1000000000000000000000000000000000000000000000000000000000000000';
const issuanceAmount = 1000;

const partition1 = '0x5265736572766564000000000000000000000000000000000000000000000000'; // Reserved in hex
const partition2 = '0x4973737565640000000000000000000000000000000000000000000000000000'; // Issued in hex
const partition3 = '0x4c6f636b65640000000000000000000000000000000000000000000000000000'; // Locked in hex
const partitions = [partition1, partition2, partition3];

contract('ERC1400Factory', function ([controller, tokenHolder, owner]) {
  beforeEach(async function () {
    this.erc1400factory = await ERC1400Factory.new(CERTIFICATE_SIGNER, partitions);
    await this.erc1400factory.createERC1400('test', 'tet', 1, [controller], { from: controller });
  });

  describe('ERC1400', function () {
    it('issueERC1400', async function () {
      let address = await this.erc1400factory.getDeployedERC1400();

      let erc1400 = await ERC1400.at(address[0]);

      await erc1400.issueByPartition(partition1, tokenHolder, issuanceAmount, VALID_CERTIFICATE, { from: owner });
    });
  });
});
0

The problem is here:

let address = await this.erc1400factory.createERC1400('test', 'tet', 1, [controller], { from: controller });

Transactions don't have return values. What you're getting back in address is probably something like the transaction hash.

You'll need to access deployedERC1400 to find out the address of the newly-created contract, something like this (completely untested):

await this.erc1400factory.createERC1400('test', 'tet', 1, [controller], { from: controller });
let address = this.erc1400factory.getDeployedERC1400().pop();
  • Thanks for the hint, I have adapted the code. But it does not work yet. – GreyFox Aug 20 at 19:35
  • Your code seems to try to assign the whole deployedERC1400 array to address instead of just the last element. I assume you tried my code first and found that it didn't work? Try printing out the value of address to debug further. – smarx Aug 20 at 20:19
  • Yes I tried your code but it does not work. I changed my code again but I still get the same error: Error: Returned error: VM Exception while processing transaction: revert. Maybe the error is caused by the inheritance at the erc 1400 – GreyFox Aug 20 at 20:33
  • Did you try printing out the value of address? What was it? – smarx Aug 20 at 21:27
  • I print out the address and get 0x282C6018b44F0752597Aa60cdE4C0C66Af159C1C, some function of the contract works but the issueByPartition not. – GreyFox Aug 21 at 10:58

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.