Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Add ITX and metadata priority to README (#284)
Browse files Browse the repository at this point in the history
* Add ITX and metadata priority to README

* Fix typo

* Address PR comments - update metadata priority README
  • Loading branch information
nmlinaric authored Mar 1, 2022
1 parent 6402512 commit f2eb63a
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,72 @@ Currently there is no CLI for this, though more information can be found about t
 
## Transaction priorities
`ChainBridge` supports making deposits with different transaction speeds. To utilize those you can
pass priority flag [`slow`/`medium`/ `fast`] when executing a [deposit](#deposit).
Transaction priorities can be implemented via `ITX`, which will be clarified below. The following example shows how to utilize the `priority` flag.
```bash
erc20 deposit
--url=**'node endpoint'**
--private-key=**'bridge admin private key'**
--amount=1
--decimals=18
--bridge=**'bridge contract address'**
--recipient=**'recipient address'**
--domain=**'domain id'**
--resource=**'registered resource'**
--priority=slow
```
### `ITX`
[Infura Transactions (ITX)](https://blog.infura.io/how-to-use-itx-step-by-step-guide/) is the simplest way to send transactions on Ethereum because it handles all edge cases for sending transactions and spares users of gas management complexities. Also a notable benefit is that it allows dapp users to send transactions without holding ETH.
 
To start using `ITX` with `ChainBridge` you'll need the following:
* setup everything according to this [guide](https://github.com/ChainSafe/chainbridge-docs/blob/develop/docs/guides/deployment-guide.md)
* create a new `Infura` project and enable `ITX` (if not enabled by default)
* register forwarder address on the bridge contract, for that use the `adminSetForwarder` function in bridge contract
* deposit some funds to the `Infura` deposit contract (these will be used for `ITX` transactions), address of the contract: `0x015C7C7A7D65bbdb117C573007219107BD7486f9` - this is the same for the following networks: `Mainnet`, `Ropsten`, `Rinkeby`, `Kovan`, `Goerli`
* modify `app.go` file with the following:
* add nonce store
```
dbNonce, err := lvldb.NewLvlDB(viper.GetString(flags.NoncestoreFlagName))
if err != nil {
panic(err)
}
nonceStore := store.NewNonceStore(dbNonce)
```
* replace `gasPricer` and `NewSignAndSendTransactor` with:
```
kp, _ := secp256k1.NewKeypairFromString(config.GeneralChainConfig.Pk)
forwarderContract := forwarder.NewForwarderContract(client, common.HexToAddress(config.GeneralChainConfig.Forwarder))
id, err := client.ChainID(context.TODO())
forwarder := itx.NewMinimalForwarder(id, kp, forwarderContract, nonceStore)
t := itx.NewITXTransactor(client, forwarder, kp)
```
### `Metadata priority`
Metadata priority enables users to make transactions with different priorities.
Since the most used use case will be implementing `metadata priority` on the front-end, we'll cover metadata design (priority length and priority).
```
metadata length: (64 bytes + recipient address length) - ((64 bytes + recipient address length) + 32 bytes)
metadata: ((64 bytes + recipient address length) + 32 bytes) - ((64 bytes + recipient address length) + 32 bytes + metadata length)
```
and then priority inside metadata is:
```
priority length: (metadataStart + metadataLength) - (metadataStart + metadataLength + 1 byte)
priority data: (metadataStart + metadataLength + 1 byte) - (metadataStart + metadataLength + 1 byte) + priority length)
```
 
## Contributing
Chainbridge-core is a open project and welcomes contributions of all kinds: code, docs, and more. If you wish to submit more complex changes,
Expand Down

0 comments on commit f2eb63a

Please sign in to comment.