Accessing StandaloneERC20 ABI that was deployed using a Factory

How do I access the ABI for an instance of a StandaloneERC20 smart contract deployed by a Factory smart contract which was created using oz SDK?

1 Like

Hi @pkr,

I don’t know if this is the best way but the ABI can be found in:

[project directory]/node_modules/@openzeppelin/contracts-ethereum-package/build/contracts/StandaloneERC20.json

Thanks @abcoathup …will this ABI be the same across all the StandaloneERC20 instances I create using the Factory?

I just tried uploading this to Terminal and it is asking for addition information such as

  • Compiler version (0.5.11+commit.c???)
  • Optimisation (y/n)

Does oz store this information somewhere on my machine from the last compile i did?

1 Like

1 Like

Hi @pkr,

The ABI should be the same across all the StandaloneERC20 instances.

The StandaloneERC20.json also includes metadata:
Compiler version 0.5.7+commit.6da8b019
Optimizer enabled: false, runs: 200

Let me start w/ a Thank You @abcoathup

I will REUPLOAD and see if Terminal is okay w/ it.

1 Like

no luck, the logs are showing this

{
"logLevel":2
"service":"contract"
"ownerId":"yNaYbqjdbmlQndwe"
"ownerType":"user"
"instanceId":1460
"metadata":"{"contractName":"0x804Ae4f68a26F62455e1911C7d85Ab6f1068FCBE","address":"0x804Ae4f68a26F62455e1911C7d85Ab6f1068FCBE","network":"ethereum_rinkeby","verificationError":"\n,SourceCode.sol:3:1: ParserError: Source \"@openzeppelin/upgrades/contracts/Initializable.sol\" not found: File import callback not supported\nimport \"@openzeppelin/upgrades/contracts/Initializable.sol\";\n^----------------------------------------------------------^\n,\n,SourceCode.sol:4:1: ParserError: Source \"ERC20Detailed.sol\" not found: File import callback not supported\nimport \"./ERC20Detailed.sol\";\n^---------------------------^\n,\n,SourceCode.sol:5:1: ParserError: Source \"ERC20Mintable.sol\" not found: File import callback not supported\nimport \"./ERC20Mintable.sol\";\n^---------------------------^\n,\n,SourceCode.sol:6:1: ParserError: Source \"ERC20Pausable.sol\" not found: File import callback not supported\nimport \"./ERC20Pausable.sol\";\n^---------------------------^\n"}"
"timestamp":1569216957610
"data":"Error while trying to verify contract: ,SourceCode.sol:3:1: ParserError: Source "@openzeppelin/upgrades/contracts/Initializable.sol" not found: File import callback not supported import "@openzeppelin/upgrades/contracts/Initializable.sol"; ^----------------------------------------------------------^ , ,SourceCode.sol:4:1: ParserError: Source "ERC20Detailed.sol" not found: File import callback not supported import "./ERC20Detailed.sol"; ^---------------------------^ , ,SourceCode.sol:5:1: ParserError: Source "ERC20Mintable.sol" not found: File import callback not supported import "./ERC20Mintable.sol"; ^---------------------------^ , ,SourceCode.sol:6:1: ParserError: Source "ERC20Pausable.sol" not found: File import callback not supported import "./ERC20Pausable.sol"; ^---------------------------^ "
"driveId":"xEXAWZjKPzoeKPRY"
"sourceOfLog":"Terminal"
"objectType":"CONTRACT"
"userId":"yNaYbqjdbmlQndwe"
}
1 Like

Hi @pkr,

Apologies, I misread the original question. I thought you were deploying StandaloneERC20 created via OpenZeppelin SDK.

You are actually deploying by a factory contract where the factory is created via OpenZeppelin SDK?

It looks like Terminal is doing a verify.

1 Like

Spot on @abcoathup

The STFactory contract is deployed using oz SDK.

And the STFactory deploys an instance of StandaloneERC20.

1 Like

Hi @pkr,

I was able to verify StandaloneERC20.

I compiled a STRegister project with the optimizer explicitly off:

oz compile --optimizer disabled

Before deploying to Ropsten and then creating a StandaloneERC20 token.

The ABI can be found in StandaloneERC20.json in build\contracts
The json also contains the compiler details.

  "compiler": {
    "name": "solc",
    "version": "0.5.11+commit.c082d0b4.Emscripten.clang",
    "optimizer": {
      "enabled": false
    },
    "evmVersion": "constantinople"
  }

I manually verified StandaloneERC20 on Ropsten: https://ropsten.etherscan.io/address/0xEBBe38147703Df6af4e29666ba719C3CB8794F90#code

(I flattened StandaloneERC20.sol from https://github.com/OpenZeppelin/openzeppelin-contracts-ethereum-package)

Hi @pkr,

How did you get on with this?

1 Like

Thank you @abcoathup,

This sort of worked, and it didn’t.

I managed to find the ABI for basic StandaloneERC20.sol, but given I am calling it from my own Factory contract…

pragma solidity >=0.5.0 <0.7.0;

/// dependencies
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/ownership/Ownable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/lifecycle/Pausable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/StandaloneERC20.sol";

contract STFactory is Initializable, Ownable, Pausable {
    using SafeMath for uint256;

I am keen to find the ABI for this compiled & deployed Factory smart contract.

The challenge, I am unable to build the API for all the oz sdk contracts I am inheriting w/in my Factory smart contract.

Any tips?

1 Like

Hi @pkr,

There will be .json for each contract can be found in build/contracts directory of your project including StandaloneERC20. Each json contains the ABI for that contract.