Transfering NYM ERC20 to NYM Cosmos for bonding or delegating in Nym mainnet — introducing Gravity…
We are in the midst of some exciting weeks in the Nym mainnet launch process:
NOTE: Please see Bridging, staking and earning NYM tokens for the latest, most up-to-date guide on how to bridge your tokens.
We are in the midst of some exciting weeks in the Nym mainnet launch process:
- NYM ERC20 tokens from the public sale have just been distributed;
- the first quarterly vesting release is about to happen, which means that people on vesting schedules will soon receive their first native NYM tokens and be able to bond and delegate stake;
- the validators are about to turn on rewards.
But what if you have ERC20 NYM and would also like to bond or delegate stake in mainnet?
This post explains how to use the Gravity Bridge to transfer your ERC20 NYM tokens to native NYM tokens, so that you can bond a node or delegate stake in the Nym mainnet.
Summary
Prerequisites:
- Nym wallet
- Basic command line skills
- Access to linux machine
- Metamask account
- Keplr wallet
- NYM ERC20
- Some ETH for tx fees
Summary of steps:
- Install Gravity Bridge binaries
- Prepare Metamask and Keplr wallets
- Go to Osmosis to get some GRAV tokens to pay Gravity Bridge tx fees
- You will need ATOM tokens to swap to GRAV
- And you will need OSMO to pay tx fees in Osmosis for swapping ATOM to GRAV
- Transfer ERC20 NYM to Gravity Bridge address (you will need some ETH for tx fees)
- IBC transfer from Gravity Bridge to Nyx blockchain (spending GRAV tx fees).
- Use Nym native wallet to start bonding and delegating your native NYM tokens! (You will need some NYM for the tx fees).
NOTE: if you want to move your tokens to an exchange you should do that from your own NYM address*, rather than attempting to deposit from IBC, as most do not support direct IBC deposits yet.*
Don’t worry — tx fees in the Cosmos ecosystem are very low. Read on for full written instructions or watch here:
(iframe src="https://www.youtube.com/embed/bnR9VuxBOvk?feature=oembed" width="700" height="393")(/iframe)
Using the Gravity Bridge
The Gravity Bridge is a bridge between the Ethereum blockchain and any Cosmos based blockchain. NYM (Cosmos) is the native token of Nym, on the Nyx blockchain. When you transfer from NYMs from Ethereum to Nyx, the bridge locks up tokens on either side, meaning the total supply of NYM tokens remains exactly 1B.
First, you need to download the binaries applicable to your system; the binaries can be found here: Bridge Binaries
You need to install two binaries, the ‘gbt’ (which enables gravity bridge transactions) and the ‘gravity binary’ (to query the gravity network).
If the binaries need permissions to execute, run chmod u+x binaryname on linux.
The gbt client has the ability to store your keys — therefore, if you see fit to run any of the following, please do:
nym@nym:~/directory$ ./gbt keys — help
gbt-keys\
Manage keys
USAGE:\
gbt keys (SUBCOMMAND)
OPTIONS:\
-h, — help Print help information
SUBCOMMANDS:\
help\
Print this message or the help of the given subcommand(s)
register-orchestrator-address\
Register delegate keys for the Gravity Orchestrator. this is a mandatory part of setting up a Gravity Orchestrator. If you would like sign using a ledger see \`cosmos tx gravity set-orchestrator-address\` instead
set-ethereum-key\
Add an Ethereum private key for use with either the Relayer or the Orchestrator
set-orchestrator-key\
Add a Cosmos private key to use as the Orchestrator address
Prepare your wallets
Install Metamask and Keplr wallet browser extensions to easily manage your NYM tokens across Cosmos and Ethereum chains.
If you do not already have a mnemonic, download the Nym wallet and generate a mnemonic (and make sure to store it somewhere safe!) You can then “import an existing account” in your Keplr wallet, by inputting your mnemonic. (Keplr will also automatically derive addresses for you for all Cosmos based chains).
Keplr support for the Nym mainnet blockchain ‘Nyx’ is in Beta, so in order for Nyx to show up, you have to inject the code below into your browser window.
You can do this by right-clicking anywhere on your browser, selecting ‘inspect’, and then navigating to the ‘console’ tab. Then paste the code below in, and press ‘return’. If this was successful, you will see a Keplr popup appear. Click yes.
//this is the code snippet to inject into the browser\
//please note staking is not currently available\
//but these values have to be inputted to use the API
await window.keplr.experimentalSuggestChain({\
chainId: "nyx",\
chainName: "Nyx Mainnet",\
rpc: "https://rpc.nyx.nodes.guru",\
rest: "https://api.nyx.nodes.guru",\
bip44: {\
coinType: 118,\
},\
bech32Config: {\
bech32PrefixAccAddr: "n",\
bech32PrefixAccPub: "n" + "pub",\
bech32PrefixValAddr: "n" + "valoper",\
bech32PrefixValPub: "n" + "valoperpub",\
bech32PrefixConsAddr: "n" + "valcons",\
bech32PrefixConsPub: "n" + "valconspub",\
},\
currencies: \[\
{\
coinDenom: "nym",\
coinMinimalDenom: "unym",\
coinDecimals: 6,\
coinGeckoId: "nym",\
},\
],\
feeCurrencies: \[\
{\
coinDenom: "nym",\
coinMinimalDenom: "unym",\
coinDecimals: 6,\
coinGeckoId: "nym",\
},\
],\
//in the future this will be updated accordingly\
//once staking is available\
//in the interim pass in the nym values as placeholders\
//do not attempt to stake, as we cant validate it will be successful\
stakeCurrency: {\
coinDenom: "nym",\
coinMinimalDenom: "unym",\
coinDecimals: 6,\
coinGeckoId: "nym",\
},\
coinType: 118,\
gasPriceStep: {\
low: 0.01,\
average: 0.025,\
high: 0.03,\
},\
features: \[\
"cosmwasm", "ibc-transfer", "ibc-go", "wasmd\_0.24+"\
],\
});
The Gravity Bridge is also a blockchain in its own right, with its own native token, gravitons (GRAV). GRAV are required to pay transaction fees to send tokens between chains. But don’t worry! Transaction fees in the Cosmos ecosystem are very low.
You can get GRAV by navigating over to Osmosis DEX. You can connect your Keplr wallet in Osmosis to begin doing transactions and swapping currencies and get your gravitons. You will need some ATOM, the Cosmos currency, which you can get from major exchanges.
In Osmosis, you will want to first purchase some OSMO if you don’t have any already, so that you can pay tx fees to swap your ATOM to GRAV, the native Gravity Bridge token. Your GRAV will now be visible on the Osmosis blockchain.
You then want to do an IBC transfer of your GRAV to your Gravity Bridge address. Use your Keplr wallet to verify that the GRAV has arrived to your Gravity Bridge account.
You can use the Cosmos block explorer ping.pub to view the Nyx blockchain as well as all your transactions and balances across Cosmos based networks. Simply attach your Keplr wallet.
Now we can finally get to the point of transferring your ERC20 NYM tokens across to native Nym tokens.
Transfering your NYM (ERC20) to native NYM (Cosmos)
Go back to your terminal and initialize the ‘gbt’ binary which enables gravity bridge transactions.
Running the help subcommand lets you know what values the executable needs in order to run.
For example: ./gbt client — help
-a, — amount (AMOUNT)
The Denom and amount you wish to send eg: 100ugraviton
-b, — bridge-fee \(BRIDGE\_FEE)
The amount you want to pay in bridge fees, these are used to pay relayers on Ethereum
and must be of the same denomination as `amount`
-c, — cosmos-phrase \(COSMOS\_PHRASE)
Cosmos mnemonic phrase containing the tokens you would like to send
— cosmos-grpc \(COSMOS\_GRPC)
(Optional) The Cosmos gRPC server that will be used to submit the transaction [default:
-e, — eth-destination \(ETH\_DESTINATION)
The destination address on the Ethereum chain
-f, — fee (FEE)
The Cosmos Denom and amount to pay Cosmos chain fees eg: 1ugraviton
On the command line:
./gbt client eth-to-cosmos \\
— ethereum-key $ETH\_PRIVATE\_KEY \ {your private eth key — you can find this from exporting it inside metamask}
— gravity-contract-address 0xa4108aA1Ec4967F8b52220a4f7e94A8201F2D906 { NYMs gravity contract address } \\
— token-contract-address 0x525A8F6F3Ba4752868cde25164382BfbaE3990e1 { Nyms token address } \\
— amount 5 \ { You can now whole NYM values — fractional / decimals amounts have not been tested, try at your own risk}
— destination gravity1YourGravityAddress
— ethereum-rpc https://mainnet.infura.io/v3/45a64f6c6fae495f82898092de839e4e
Why do you provide your ETH private keys? This is to provide the cost of transaction fees for sending tokens to the gravity bridge. (This document doesn’t highlight best practices regarding security, but make sure your private keys and sensitive information are kept secure at all times!)
When sending from the gravity bridge, you need to ensure you have Gravitons (GRAV) to perform transactions for fees on their chain.
NOTE: for the transfer to be actioned quickly, you need to specify the bridge-fee. This value will be in NYMs, in their minor representation, unyms:
10000000 = 10 NYMs
100000000 = 100 NYMs
1000000000 = 1000 NYMs
The higher the fee, the sooner your transaction may be picked up by a relayer. This value is deducted from your NYM balance in your gravity bridge address.
Once you’ve submitted the transaction, you can check the status of the request,
If you have your wallet connected via Keplr or ping.pub you can see this in your wallet overview, otherwise you can query the chain using the `gravity` binary.
After you run the command from the terminal, messages will be outputted to the console informing of a successful transaction.
You can check your ETH wallet balance to see the fees that were deducted. Then in 5 mins or less your Gravity Bridge balance will be updated with your newly relayed NYM tokens on the Gravity Bridge.
From there, you can transfer the gravity bridge tokens to your NYM address.
Since we have already injected the Nyx blockchain information into Keplr, you can simply navigate to ping.pub, import your wallets, and then use the interface to send your Nyx between your Gravity and Nym addresses via IBC.
You have now successfully performed an ERC20 conversion to Cosmos, moving your NYM tokens from Ethereum to the Nyx blockchain.
Open your Nym wallet and you should now see your native NYM tokens, ready for you to start bonding and delegating in the Nym privacy mainnet!
NOTE that the minimum bond to run a node is 100 NYMs so if you want to bond a mixnode or a gateway, do ensure you transfer a minimum of 101 NYMs (100 for bond plus 1NYM to cover tx fees).