Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERC-20 token import #808

wants to merge 32 commits into from


None yet
2 participants
Copy link

commented Feb 15, 2019

Issue/Task Number: #701
Closes #701
Require #693

⚠️ Work in progress. Preliminary reviews for red flags are appreciated!


This PR adds a new endpoint /token.import that allows the admin to import an existing ERC-20 token on the blockchain into the eWallet.


  • Add EWallet.TokenGate to support business logic for token import.
  • Also moved /token.create business logic into this EWallet.TokenGate.
  • Add AdminAPI.V1.TokenController.import/1
  • Add a GethSimulator (pun intended) to simulate request/response from geth. Used for testing.
  • Add a new ledger field to the existing EWalletDB.Token to identify the token's residing ledger. Either ledger: "local" or ledger: "external"

Implementation Details

The ExternalLedger.TemporaryAdapter is intended for use during this PR's development only. It should be replaced completely with the adapter that will come out of #693.

Basic flow

  1. An admin makes a request to /token.import with contract_address and adapter.
  2. The eWallet looks up the contract address from the blockchain tied to the given adapter above.
  3. If the contract with the given address is found, the eWallet creates an EWalletDB.Token and ExternalLedgerDB.Token corresponding to that token contract.
    • Alternative path: If the admin provides token info such as name, symbol, subunit_to_unit, etc. The admin-provided info overrides the values from the token contract.
  4. Errors if the token contract could not be retrieved, or if there's any duplicate token name or symbol already inside the eWallet.

Not implemented yet

  • Adapter switching
  • Extensive testing for unhappy paths
  • Token transactions on external ledger tokens (or prevention thereof)



curl \
-H "Accept: application/vnd.omisego.v1+json" \
-H "Authorization: OMGAdmin <truncated>" \
-H "Content-Type: application/json" \
-d '{
  "contract_address": "0x546a574ed633786b6a42f909753c1f7f6f37993a",
  "adapter": "ethereum"
}' \
-v -w "\n" | jq


  "success": true,
  "version": "1",
  "data": {
    "created_at": "2019-02-15T18:29:51.748331Z",
    "enabled": true,
    "encrypted_metadata": {},
    "id": "tok_OMG_01d3s6r1029k1222vjv1epzdzr",
    "ledger": "external",
    "metadata": {},
    "name": "OmiseGO Rinkeby Testnet",
    "object": "token", 
    "subunit_to_unit": 1000000000000000000,
    "symbol": "OMG",
    "updated_at": "2019-02-15T18:29:51.748331Z"}

Request with full overrides

curl \
-H "Accept: application/vnd.omisego.v1+json" \
-H "Authorization: OMGAdmin <truncated>" \
-H "Content-Type: application/json" \
-d '{
  "contract_address": "0x546a574ed633786b6a42f909753c1f7f6f37993a",
  "adapter": "ethereum",
  "name": "OmiseGO",
  "symbol": "OMG",
  "subunit_to_unit": 10000
}' \
-v -w "\n" | jq


How can this change be deployed? Any special requirement?

unnawut added some commits Feb 8, 2019

@unnawut unnawut added this to the v1.2 milestone Feb 15, 2019

@unnawut unnawut self-assigned this Feb 15, 2019

@ghost ghost added the s2/wip 🚧 label Feb 15, 2019

unnawut added some commits Feb 18, 2019

@unnawut unnawut force-pushed the 701-token-import branch from da0a252 to 93cf644 Feb 18, 2019

unnawut added some commits Feb 15, 2019

@unnawut unnawut force-pushed the 701-token-import branch from 93cf644 to 45674bf Feb 20, 2019

unnawut added some commits Feb 20, 2019

@unnawut unnawut force-pushed the 690-blockchain-wallet-schema branch from 22d5f87 to ada52d3 Feb 26, 2019

@unnawut unnawut changed the base branch from 690-blockchain-wallet-schema to master Mar 1, 2019

@T-Dnzt T-Dnzt modified the milestones: v1.2, v2.0 Mar 7, 2019


This comment has been minimized.

Copy link
Collaborator Author

commented Mar 13, 2019

Closing this for now. Will re-submit once integrated with #807 changes

@unnawut unnawut closed this Mar 13, 2019

@ghost ghost removed the s2/wip 🚧 label Mar 13, 2019

@unnawut unnawut deleted the 701-token-import branch Mar 13, 2019

@nebali nebali referenced this pull request Mar 13, 2019


Ethereum integration. (v2.0) #48

12 of 51 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.