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

Fix examples #199

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/.env.mainnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
###> all ###
DEBRIDGEGATE_ADDRESS="0x43dE2d77BF8027e25dBD179B491e8d64f38398aA"
DEPLOYER_PRIVATE_KEY=""
SENDER_PRIVATE_KEY=""
###< all ###

Expand All @@ -25,3 +26,5 @@ ROUTER_ADDRESS=""
API_ENDPOINT="https://api.debridge.finance"
MIN_CONFIRMATIONS=7
###< claim.ts ###

ETHERSCAN_KEY=
5 changes: 4 additions & 1 deletion examples/.env.testnet
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
###> all ###
DEBRIDGEGATE_ADDRESS="0x68D936Cb4723BdD38C488FD50514803f96789d2D"
DEPLOYER_PRIVATE_KEY=""
SENDER_PRIVATE_KEY=""
###< all ###

###> send.ts, sendERC20.ts ###
#From BSC
#From BSC testnet
CHAIN_ID_FROM=97
#To KOVAN
CHAIN_ID_TO=42
Expand All @@ -26,3 +27,5 @@ ROUTER_ADDRESS="0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
API_ENDPOINT="https://testapi101.debridge.finance"
MIN_CONFIRMATIONS=7
###< claim.ts ###

ETHERSCAN_KEY=
42 changes: 28 additions & 14 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ This repository demonstrates how to interact with deBridge infrastructure in ord

In order to run scripts please configure your local environment first:

1. `yarn install && yarn hardhat compile && yarn typechain --target web3-v1 --out-dir typechain-types-web3 "{artifacts/{contracts,@openzeppelin}/**/*[!dbg].json,./node_modules/@uniswap/v2-periphery/build/[!Combined]*.json}"`
3. Configure .env file — copy values from .env.testnet or .env.mainnet for the testnet and mainnet environments respectively. You may copy them to .env either in top-level or inside this dir
1. Configure .env file — copy values from .env.testnet or .env.mainnet for the testnet and mainnet environments respectively. Copy them to .env either in top-level dir

2. In top-level dir execute command (works in bash, doesn't work in zsh)

`yarn install && yarn hardhat compile && yarn typechain --target web3-v1 --out-dir typechain-types-web3 "{artifacts/{contracts,@openzeppelin}/**/*[!dbg].json,./node_modules/@uniswap/v2-periphery/build/[!Combined]*.json}"`

3. Get test tokens

https://testnet.binance.org/faucet-smart
https://faucets.chain.link/

### Sending of the Base Asset

Expand All @@ -29,7 +37,8 @@ Please note the resulted `SubmissionID` which will be needed during the claim s

### Sending of the ERC-20 token

execute ```yarn ts-node examples/src/sendScripts/sendETH.ts``` to send ERC-20 token
[doesn't work yet]
execute ```yarn ts-node examples/src/sendScripts/sendERC20.ts``` to send ERC-20 token

Please note the resulted `SubmissionID` which will be needed during the claim step

Expand All @@ -47,7 +56,7 @@ The protocol implements [locking and minting](https://docs.debridge.finance/the-
In order to have the transaction executed in the target chain, it should be claimed by passing all parameters of the transaction alongside signatures of submissionId from all deBridge validators.

In order to claim transaction execute
```yarn ts-node examples/src/sendScripts/calim.ts [submissionId]```
```yarn ts-node examples/src/sendScripts/claim.ts [submissionId]```


# [BridgeAppBase.sol](/contracts/examples/BridgeAppBase.sol) — cross-chain application base contract called from other chains
Expand Down Expand Up @@ -102,22 +111,27 @@ This example shows how to send a message between two chains using Incrementor.so

### Sending a message using example scripts
1. Add `networks` to your hardhat.config.ts, see hardhat.config.ts in this repo for reference
2. Deploy
2. Deploy incrementorScripts for source network
```shell
yarn hardhat run --network bsctest examples/src/incrementorScripts/deploy.ts
```
[why not in .env file?]
Update addresses (INCREMENTOR_ADDRESS_ON_FROM) in examples/src/incrementorScripts/constants.ts to `incrementorScripts proxy`
addresses (will be printed in console)

3. Deploy incrementorScripts for destination network
```shell
yarn hardhat run --network kovan examples/src/incrementorScripts/deploy.ts
```
3. Update addresses (INCREMENTOR_ADDRESS_ON_*) in constants.ts to `Incrementor proxy` addresses (will be printed in console)
[why not in .env file?]
Update addresses (INCREMENTOR_ADDRESS_ON_TO) in examples/src/incrementorScripts/constants.ts to `incrementorScripts proxy`
addresses (will be printed in console)

4. Verify (optional)
- Add `import "@nomiclabs/hardhat-etherscan";` to your hardhat.config.ts, install it if it's not installed
- Also add this line
```typescript
etherscan: { apiKey: process.env.ETHERSCAN_API_KEY }
```
- IMPLEMENTATION_ADDRESS is `Incrementor implementation` printed in console
- IMPLEMENTATION_ADDRESS is `Incrementor implementation` printed in console (will not work with not ethereum networks)
```shell
ETHERSCAN_API_KEY=YOUR_KEY yarn hardhat verify --show-stack-traces --network bsctest IMPLEMENTATION_ADDRESS
ETHERSCAN_API_KEY=YOUR_KEY yarn hardhat verify --show-stack-traces --network kovan IMPLEMENTATION_ADDRESS
yarn hardhat verify --show-stack-traces --network bsctest IMPLEMENTATION_ADDRESS
yarn hardhat verify --show-stack-traces --network kovan IMPLEMENTATION_ADDRESS
```
5. Let both contracts know about each other
```shell
Expand Down
4 changes: 0 additions & 4 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ export default {
accounts:{mnemonic:process.env.MNEMONIC},
chainId: 1
},
test: {
url: "http://127.0.0.1:8545",
accounts: {mnemonic:process.env.MNEMONIC},
},
kovan: {
url: "https://kovan.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",
accounts: [process.env.DEPLOYER_PRIVATE_KEY],
Expand Down