æternity Documentation Hub
Aeternity.comAeternity GitHub
  • æternity Hub
  • Developer Documentation
  • Aeternity Expansions
    • PULL_REQUEST_TEMPLATE
    • AEX X
    • AEXS
      • AEX 1
      • aex-10
      • AEX 11 Fungible Token Standard
      • AEX-130: æpps Metadata Format Specification
      • aex-141
      • AEX 2
      • AEX-3
      • AEX-4
      • AEX 5
      • AEX 7
      • AEX 8
      • aex-9
    • .github
      • ISSUE_TEMPLATE
        • aexpansion
  • AeMdw - Aeternity Middleware
    • Changelog
    • docs
      • AE MDW Architecture
      • AeMdw Hyperhain Setup Documentation
      • AeMdw Docker Setup Documentation
  • Æternity <> Ethereum Bridge
    • Changelog
  • aepp-cli-js
    • CHANGELOG
    • Contributor guide
    • reference
    • user-guide
    • .github
      • ISSUE_TEMPLATE
  • Hyperchain Bridge
    • Changelog
  • æternity's JavaScript SDK
    • Installation
      • Changelog
      • Compatibility Table
      • Quick Start
      • Transaction options
      • Development
        • Releases
      • guides
        • The range of possible address length
        • AENS (æternity naming system)
        • Batch Transactions
        • How to build a wallet
        • Connect an æpp to a wallet
        • Contract Events
        • Contracts
        • Error Handling
        • JWT usage
        • Ledger Hardware Wallet
        • Low vs High level API
        • Aeternity snap for MetaMask
        • Oracles
        • PayingForTx (Meta-Transactions)
        • Typed data hashing and signing
        • Usage with TypeScript
        • migration
          • Migration to 10.0.0
          • Migration to 11.0.0
          • Migration to 12.0.0
          • Migration to 13.0.0
          • Migration to 14.0.0
          • Migration to 7.0.0
          • Migration to 9.0.0
      • tutorials
        • vuejs
          • Vue.js HelloWorld
    • Examples
      • How to connect wallet to æpp using æternity's JS SDK
        • Sample æpp for contracts
        • iframe-based wallet
        • WebExtension-based wallet
    • .github
      • ISSUE_TEMPLATE
        • bug_report
        • feature_request
  • AEproject
    • Changelog
    • docs
      • Quick Start
      • AEproject Library
      • Migration from 3.x.x to 4.x.x
      • Migration from 4.x.x to 5.x.x
      • Upcoming Version Support
      • cli
        • Local Environment
        • Project Initialization
        • Unit Testing
    • .github
      • ISSUE_TEMPLATE
        • bug_report
        • feature_request
  • aerepl
    • Changelog
  • aescan
    • Changelog
    • Contributor Covenant Code of Conduct
    • Aescan Contributing Guide
    • LICENSE
    • .github
      • pull_request_template
      • ISSUE_TEMPLATE
        • bug_report
        • feature_request
    • docs
      • BRANCHING_STRATEGY
  • Sophia Support for Visual Studio Code
    • Changelog
  • aesophia
    • Changelog
    • Contributing to Sophia
    • docs
      • aeso_aci
      • aeso_compiler
      • Introduction
      • sophia
      • Contract examples
      • Features
      • Standard library
      • Syntax
  • aesophia_cli
    • Changelog
  • aesophia_http
    • Changelog
  • Æ Studio - Formerly known as 🔥 Fire Editor ! Aeternity's easy to use editor for writing smart contr
    • ideas
  • aeternity
    • .github
      • The Æternity Code of Conduct
      • Contributing to the Aeternity node
      • ISSUE_TEMPLATE
        • bug_report
        • feature_request
    • Welcome to Aeternity node documentation
      • Summary
      • Node API
      • Introduction
      • Build from source
      • Configuration
      • CUDA Miner
      • debian_ubuntu_packaging
      • Docker
      • Fork resistance in Aeternity nodes
      • Garbage Collection
      • Hacking the Aeternity Codebase
      • Hardware Requirements
      • hyperchains
      • Installation
      • Network Monitoring
      • Operation
      • Rebar Quick Guide
      • Stratum
      • Testing
      • Update
      • release-notes
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • About this release
        • next-ceres
          • GH-3706-micro_block_gas_limit_used_gas
          • GH-4009-allow_contract_call_by_name
          • GH-4056-add_raw_data_pointers_to_AENS
          • GH-4080-wildcard_aens_delegation_signature
          • GH3417-tamper_protection_on_ga_meta_tx
          • aega_only_allow_attach_for_fresh_accounts
          • aens_auction_adjustments
          • aens_preclaim_optional
          • deprecate_swagger
          • fate_extensions
        • next
          • GH-3088-db_direct_access-as-default
          • GH-4087_http_endpoint_info_inner_txs
          • GH4157-control-mempool-sync-start
    • Emergency patching of OTP modules
    • rosetta
    • apps
      • aehttp
        • priv
          • rosetta_README
    • data
      • aecore
        • Token migration contract
  • Hyperchains whitepaper
    • Hyperchains: Bridging Security and Scalability Through Periodic Synchronization
    • LICENSE
    • Periodically-Syncing-HyperChains
    • generations
    • Glossary
    • Hyperchain Properties
    • staking
  • æternity protocol
    • æternity naming system
    • Gossip
    • Stratum
    • SYNC
    • Serialization formats
    • State Channels
      • Off-chain
      • On-chain
      • Authentication
      • Channel off-chain state
    • æternity consensus protocol
      • Bitcoin-NG for æternity
      • Coinbase at height
      • consensus
      • Coins locking
    • Smart Contracts
      • The æternity Ethereum virtual machine (AEVM)
      • contract_state_tree
      • Contract Transactions
      • Virtual machines on the æternity blockchain
      • contracts
      • Events
      • fate
      • The Solidity Language
      • sophia
      • sophia_stdlib
    • Generalized accounts
      • Generalized accounts - explained
      • generalized_accounts
    • Oracles
      • Oracle life cycle examples
      • Oracle state tree
      • Oracle transactions
      • oracles
    • Sync
      • P2P messages
      • Mempool/TX-pool synchronization
    • node
      • æternity node API
        • Account management - intended usage
        • Encoding scheme for API identifiers and byte arrays
        • State channel WebSocket API
        • Channels - intended usage
        • Contracts - intended usage
        • Mining - intended usage
        • Naming System - intended usage
        • Oracles - intended usage
        • Spending coins - intended usage
        • examples
          • æternity node channel WebSocket API examples
            • json-rpc
              • sc_ws_basic_open_close
              • sc_ws_basic_open_close_server
              • sc_ws_broken_open_params
              • sc_ws_close_mutual
              • sc_ws_close_solo
              • sc_ws_leave_reconnect
              • sc_ws_leave_reestablish
              • sc_ws_leave_reestablish_responder_stays
              • sc_ws_leave_reestablish_wrong_fsm_id
              • sc_ws_min_depth_is_modifiable
              • sc_ws_min_depth_not_reached_timeout
              • sc_ws_opening_ping_pong
              • sc_ws_reconnect_early
              • sc_ws_slash
              • sc_ws_snapshot_solo
              • sc_ws_timeout_open
              • sc_ws_update_with_meta
              • abort_updates
                • sc_ws_abort_deposit
                • sc_ws_abort_offchain_update
                • sc_ws_abort_settle
                • sc_ws_abort_shutdown
                • sc_ws_abort_slash
                • sc_ws_abort_snapshot_solo
                • sc_ws_abort_withdraw
                • sc_ws_can_not_abort_while_open
              • assume_min_depth
                • sc_ws_basic_open_close
              • both_sign
                • init_per_group
                • conflicts
                  • sc_ws_conflict_deposit_and_offchain_update
                  • sc_ws_conflict_two_deposits
                  • sc_ws_conflict_two_offchain_updates
                  • sc_ws_conflict_two_withdrawals
                  • sc_ws_conflict_withdrawal_and_deposit
                  • sc_ws_conflict_withdrawal_and_offchain_update
              • changeable_fee
                • sc_ws_optional_params_close_solo
                • sc_ws_optional_params_create
                • sc_ws_optional_params_deposit
                • sc_ws_optional_params_settle
                • sc_ws_optional_params_slash
                • sc_ws_optional_params_snapshot
                • sc_ws_optional_params_withdrawal
                • sc_ws_set_fee_close_mutual
                • sc_ws_set_fee_close_solo
                • sc_ws_set_fee_create
                • sc_ws_set_fee_deposit
                • sc_ws_set_fee_settle
                • sc_ws_set_fee_slash
                • sc_ws_set_fee_snapshot
                • sc_ws_set_fee_withdrawal
              • changeable_fee_higher_than_gas_price
                • sc_ws_optional_params_close_solo
                • sc_ws_optional_params_create
                • sc_ws_optional_params_deposit
                • sc_ws_optional_params_settle
                • sc_ws_optional_params_slash
                • sc_ws_optional_params_snapshot
                • sc_ws_optional_params_withdrawal
              • changeable_fee_lower_than_gas_price
                • sc_ws_optional_params_close_solo
                • sc_ws_optional_params_create
                • sc_ws_optional_params_deposit
                • sc_ws_optional_params_settle
                • sc_ws_optional_params_slash
                • sc_ws_optional_params_snapshot
                • sc_ws_optional_params_withdrawal
              • changeable_gas_price
                • sc_ws_optional_params_close_solo
                • sc_ws_optional_params_create
                • sc_ws_optional_params_deposit
                • sc_ws_optional_params_settle
                • sc_ws_optional_params_slash
                • sc_ws_optional_params_snapshot
                • sc_ws_optional_params_withdrawal
              • changeable_nonce
                • sc_ws_optional_params_fail_close_mutual
                • sc_ws_optional_params_fail_close_solo
                • sc_ws_optional_params_fail_create
                • sc_ws_optional_params_fail_deposit
                • sc_ws_optional_params_fail_force_progress
                • sc_ws_optional_params_fail_settle
                • sc_ws_optional_params_fail_slash
                • sc_ws_optional_params_fail_snapshot
                • sc_ws_optional_params_fail_withdrawal
              • continuous
                • init_per_group
                • sc_ws_deposit
                • sc_ws_failed_update
                • sc_ws_generic_messages
                • sc_ws_ping_pong
                • sc_ws_update_conflict
                • sc_ws_withdraw
              • contracts
                • init_per_group
                • sc_ws_basic_contracts
                • sc_ws_environment_contract
                • sc_ws_nameservice_contract
                • sc_ws_oracle_contract
                • sc_ws_remote_call_contract
                • sc_ws_remote_call_contract_refering_onchain_data
                • sc_ws_wrong_call_data
              • force_progress
                • sc_ws_force_progress_based_on_offchain_state
                • sc_ws_force_progress_based_on_onchain_state
              • only_one_signs
                • init_per_group
                • sc_ws_conflict_on_new_offchain
                • sc_ws_conflict_snapshot_and_offchain_update
                • conflicts
                  • sc_ws_conflict_deposit_and_offchain_update
                  • sc_ws_conflict_two_deposits
                  • sc_ws_conflict_two_offchain_updates
                  • sc_ws_conflict_two_withdrawals
                  • sc_ws_conflict_withdrawal_and_deposit
                  • sc_ws_conflict_withdrawal_and_offchain_update
              • reconnect
                • sc_ws_basic_client_reconnect_i
                • sc_ws_basic_client_reconnect_i_w_reestablish
                • sc_ws_basic_client_reconnect_r
              • with_meta
                • init_per_group
                • sc_ws_deposit
                • sc_ws_remote_call_contract
                • sc_ws_withdraw
              • generalized_accounts
                • both
                  • sc_ws_basic_open_close
                • initiator
                  • sc_ws_basic_open_close
                • responder
                  • sc_ws_basic_open_close
  • Superhero Wallet
    • Changelog
    • Contributing & Guidelines
    • docs
      • Deep link URL Schema
    • .github
      • ISSUE_TEMPLATE
        • bug_report
        • feature_request
  • aerepl-web-bridge
    • AereplApi
    • aerepl_components
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. aeternity
  2. data
  3. aecore

Token migration contract

In the Lima hard-fork the remaining (frozen) Aeternity tokens from the Ethereum ERC20 contract are put into a contract and can be retreived by the entity holding the correct Ethereum private key. This contract is added to chain as part of the hard-fork, and the contract is also funded as part of the hard-fork. Here we describe how we prepare the data (the contracts.json file) that is used during the hard-fork. The .json-file has the following format and constraints (apps/aecore/src/aec_fork_block_settings.erl):

%%% { <API encoded pubkey for contract> : { "amount" : <integer>,
%%%                                         "vm_version" : <integer>,
%%%                                         "abi_version" : <integer>,
%%%                                         "nonce" : <integer>
%%%                                         "code" : <API encoded contract byte array>
%%%                                         "call_data" : <API encoded contract byte array>
%%%                                       }
%%% ...
%%% }
%%%
%%% The locked token account will be the owner of the contracts.
%%% The nonces must correspond to the nonces of the owner account.
%%% The nonces must be consecutive (but not necessarity ordered)
%%% The pubkey of the contract must correspond to the computed pubkey
%%%    (based on owner account and nonce). This is mostly a fail safe to ensure
%%%    that the contract pubkey is visible in the file.

Since this is the first contract to be added by this mechanism, the nonce to be used is 1 and we can compute the contract pubkey using Erlang:

25> Locked = aec_governance:locked_coins_holder_account(), Nonce = 1.
1
26> CtPK = aect_contracts:compute_contract_pubkey(Locked, Nonce).
<<84,180,196,235,185,254,235,68,37,168,101,128,127,111,97,
  136,141,11,134,251,228,200,73,71,175,98,22,115,172,...>>
27> aeser_api_encoder:encode(contract_pubkey, CtPK).
<<"ct_eJhrbPPS4V97VLKEVbSCJFpdA4uyXiZujQyLqMFoYV88TzDe6">>

Then we need to compute the total sum of tokens. The final list of accounts that has not migrated their tokens is in test/json/contracts_accounts.json. The sum of the tokens is:

79> mtree:total_sum_from_json("../test/json/contracts_accounts.json").
29622067581238053773524138

We also need the root-hash of the Merkle tree (the tree contains all the Ethereum accounts and their respective balances).

80> BigT = mtree:tree_from_json("../test/json/contracts_accounts.json"), ok.
ok
81> mtree:root_hash(BigT).
"E4DBC69BF2783B81B0423DA3F5B684C1D37CCFAE798474525C4001DB42C67669"
aeternity : ls -l test/contracts/token_migration.aes
-rw-r--r--  1 hans  staff  3966 Sep 27 10:39 test/contracts/token_migration.aes
aeternity : md5 test/contracts/token_migration.aes
MD5 (test/contracts/token_migration.aes) = 56ead7528cb20700e148566e5683b5c0
aeternity : md5 ../aesophia_cli/priv/bin/v4.0.0-rc5/aesophia_cli
MD5 (../aesophia_cli/priv/bin/v4.0.0-rc5/aesophia_cli) = 39ae10aa26838dc99f5caae5f43d98ff
aeternity : ../aesophia_cli/priv/bin/v4.0.0-rc5/aesophia_cli test/contracts/token_migration.aes
Bytecode:
cb_+QP9RgOguo6qpyu/hfk5d+qq/tgbo35YmOc3e32WGzPH9WKYCUnAuQPLuQL0/gYNP1AANwUHRwAHJ3eXbwEHfAQCBwwgDAOBUGFzc2VkIEFFIGFkZHJlc3MgaXMgbm90IHBheWFibGX7ABoCb4ImzzwGAgI+CAI7ADogAjoOBGkZRXRoZXJldW0gU2lnbmVkIE1lc3NhZ2U6CgwBCBsIBAIDEeg39H8aAggIPggcHhoCCgwCCgIDEcnWapQmAAcMGgwDvVRoaXMgYWNjb3VudCBoYXMgYWxyZWFkeSB0cmFuc2ZlcnJlZCBpdHMgdG9rZW5z+wAaAm+CJs8MAQYMAQQMAQAMAgoCAxFdcNL1BwwYDAPFRnJvbSBwcm92aWRlZCBkYXRhLCBjYW5ub3QgYmUgZ2VuZXJhdGVkIHNhbWUgcm9vdPsAGgJvgibPDAEADAECZQAoLAKCEAwCgikMAhoCFCguFgQULegWCj8MAhQpDAQaAoIMAgoMAQIMAQBE/BMGAAYCAxFlpeAPGgJvgibPKCwCggAMAz8GAxQMAz8GAw4MA6FGYWlsZWQgdG8gcmVjb3ZlciBhZGRyZXNzLCBiYWQgc2lnbmF0dXJl+wBGOgoIAEAICjoMCTBYBgMIDAM/BgME/kTWRB8ANwJ3BzcADAEADAECKgAnDAYaAoIBAz/+XXDS9QA3BHcHByd3FzsEAjoMBTo6BgAAGwgAQAAMAQQMAQYCAxHsL+O+GgIEKCwAgiAIBAD+ZaXgDwI3AYcBNwN3RwAHNwBGNAAERjQAAgwDnwGBR4YJ0hFJn+CFQlrEPeWHXqVaT+74Y8OnTxa1W2+3OL1GNAAAYwABAz/+tIwWhAA3AAdTAAD+u6I84gA3AHcoLACCAP7J1mqUADcBdxcoLASCLxAAAP7YuSNvADcABygsAoIA/ug39H8CNwKXQJdvAYcCNwA3AZcofxQAAgD+7C/jvgI3Ayd3B3d3MwQABwwMNQYAADYGAgAYNAIEIDACBwwKOiQEAAYDBhoCBBsIBEABBBoJAAIXNQICBAYDAAA6GAAEBgMGAQEEuM8vChEGDT9QHW1pZ3JhdGURRNZEHxFpbml0EV1w0vVhY29udGFpbmVkX2luX21lcmtsZV90cmVlEWWl4A8tQ2hhaW4uZXZlbnQRtIwWhB1iYWxhbmNlEbuiPOIlcm9vdF9oYXNoEcnWapQtaXNfbWlncmF0ZWQR2Lkjb0FtaWdyYXRpb25zX2NvdW50Eeg39H9pLlRva2VuTWlncmF0aW9uLmdldF9zaWduZXIR7C/jvnkuVG9rZW5NaWdyYXRpb24uY2FsY3VsYXRlX3Jvb3SCLwCJNC4wLjAtcmM1AIUFMq4=
aeternity : ../aesophia_cli/priv/bin/v4.0.0-rc5/aesophia_cli --create_calldata test/contracts/token_migration.aes --calldata_fun init --calldata_args "\"E4DBC69BF2783B81B0423DA3F5B684C1D37CCFAE798474525C4001DB42C67669\", 0"
Calldata:
cb_KxFE1kQfKwEARTREQkM2OUJGMjc4M0I4MUIwNDIzREEzRjVCNjg0QzFEMzdDQ0ZBRTc5ODQ3NDUyNUM0MDAxREI0MkM2NzY2OQDtuA/R

The resulting data is then:

{
    "ct_eJhrbPPS4V97VLKEVbSCJFpdA4uyXiZujQyLqMFoYV88TzDe6" :
        { "amount"      : 29622067581238053773524138,
          "vm_version"  : 5,
          "abi_version" : 3,
          "nonce"       : 1,
          "code"        : "cb_+QP9RgOguo6qpyu/hfk5d+qq/tgbo35YmOc3e32WGzPH9WKYCUnAuQPLuQL0/gYNP1AANwUHRwAHJ3eXbwEHfAQCBwwgDAOBUGFzc2VkIEFFIGFkZHJlc3MgaXMgbm90IHBheWFibGX7ABoCb4ImzzwGAgI+CAI7ADogAjoOBGkZRXRoZXJldW0gU2lnbmVkIE1lc3NhZ2U6CgwBCBsIBAIDEeg39H8aAggIPggcHhoCCgwCCgIDEcnWapQmAAcMGgwDvVRoaXMgYWNjb3VudCBoYXMgYWxyZWFkeSB0cmFuc2ZlcnJlZCBpdHMgdG9rZW5z+wAaAm+CJs8MAQYMAQQMAQAMAgoCAxFdcNL1BwwYDAPFRnJvbSBwcm92aWRlZCBkYXRhLCBjYW5ub3QgYmUgZ2VuZXJhdGVkIHNhbWUgcm9vdPsAGgJvgibPDAEADAECZQAoLAKCEAwCgikMAhoCFCguFgQULegWCj8MAhQpDAQaAoIMAgoMAQIMAQBE/BMGAAYCAxFlpeAPGgJvgibPKCwCggAMAz8GAxQMAz8GAw4MA6FGYWlsZWQgdG8gcmVjb3ZlciBhZGRyZXNzLCBiYWQgc2lnbmF0dXJl+wBGOgoIAEAICjoMCTBYBgMIDAM/BgME/kTWRB8ANwJ3BzcADAEADAECKgAnDAYaAoIBAz/+XXDS9QA3BHcHByd3FzsEAjoMBTo6BgAAGwgAQAAMAQQMAQYCAxHsL+O+GgIEKCwAgiAIBAD+ZaXgDwI3AYcBNwN3RwAHNwBGNAAERjQAAgwDnwGBR4YJ0hFJn+CFQlrEPeWHXqVaT+74Y8OnTxa1W2+3OL1GNAAAYwABAz/+tIwWhAA3AAdTAAD+u6I84gA3AHcoLACCAP7J1mqUADcBdxcoLASCLxAAAP7YuSNvADcABygsAoIA/ug39H8CNwKXQJdvAYcCNwA3AZcofxQAAgD+7C/jvgI3Ayd3B3d3MwQABwwMNQYAADYGAgAYNAIEIDACBwwKOiQEAAYDBhoCBBsIBEABBBoJAAIXNQICBAYDAAA6GAAEBgMGAQEEuM8vChEGDT9QHW1pZ3JhdGURRNZEHxFpbml0EV1w0vVhY29udGFpbmVkX2luX21lcmtsZV90cmVlEWWl4A8tQ2hhaW4uZXZlbnQRtIwWhB1iYWxhbmNlEbuiPOIlcm9vdF9oYXNoEcnWapQtaXNfbWlncmF0ZWQR2Lkjb0FtaWdyYXRpb25zX2NvdW50Eeg39H9pLlRva2VuTWlncmF0aW9uLmdldF9zaWduZXIR7C/jvnkuVG9rZW5NaWdyYXRpb24uY2FsY3VsYXRlX3Jvb3SCLwCJNC4wLjAtcmM1AIUFMq4=",
          "call_data"   : "cb_KxFE1kQfKwEARTREQkM2OUJGMjc4M0I4MUIwNDIzREEzRjVCNjg0QzFEMzdDQ0ZBRTc5ODQ3NDUyNUM0MDAxREI0MkM2NzY2OQDtuA/R"
        }
}
PreviousaecoreNextHyperchains whitepaper

Last updated 28 days ago

Was this helpful?

Finally we need to compile the contract , and the contract init call data:

available HERE