-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added support of erc721 * cleanup * fixes for sdk for erc721 example * erc721 example local build * updated yarn lock * added scripts for minting * update config to new local setup * update readme * fix readme * use localy compile sdk version * update erc20 react example * delete old react example * adding sygma contracts dependency on package.json for react example * update bridge setup to work with updated local setup * update bridge setup for nft example Co-authored-by: Nicolas Riquelme <[email protected]>
- Loading branch information
Showing
27 changed files
with
131 additions
and
170 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<p align="center"><a href="https://https://chainsafe.io/"><img width="250" title="Chainbridge UI" src='../../assets/full-logo.png'/></a></p> | ||
|
||
## Sygma SDK ERC20 React Example | ||
<p align="center"> | ||
<img widht="700" src='./public/erc20-example-screen.png' alt="screen" /> | ||
</p> | ||
|
||
This simple React application demonstrate the usage of our SDK methods, alongside with the [Sygma](https://github.com/sygmaprotocol/sygma-relayer) local setup. | ||
|
||
### Getting started | ||
#### Installing and building sdk | ||
Before running the erc20 example you need to clone the repo and then install dependencies: | ||
|
||
```bash | ||
git clone [email protected]:sygmaprotocol/sygma-sdk.git | ||
cd sygma-sdk | ||
yarn | ||
``` | ||
|
||
then compile sdk with following command: | ||
```bash | ||
# from the repository root | ||
cd ./packages/sdk | ||
yarn tsc | ||
``` | ||
|
||
|
||
#### Local setup | ||
To run our local setup please follow insturctions in [sygma-relayer repo](https://github.com/sygmaprotocol/sygma-relayer#local-environment) | ||
|
||
In the end you should have 2 geth nodes running on `localhost:8545` and `localhost:8547` and two relayers running | ||
|
||
### Running the react app | ||
first change directory to erc20 directory: | ||
|
||
```bash | ||
# from the repository root | ||
cd examples/erc20-react-example | ||
``` | ||
|
||
Mint 99 ERC20 token for test: | ||
```bash | ||
# from examples/erc20-react-example | ||
yarn mintERC20 | ||
``` | ||
Please add private key `0xcc2c32b154490f09f70c1c8d4b997238448d649e0777495863db231c4ced3616` | ||
and erc20 token `0x1CcB4231f2ff299E1E049De76F0a1D2B415C563A` to metamask | ||
<p align="center"> | ||
<img widht="200" src='./public/metamask0.png' alt="screen" /> | ||
<img widht="200" src='./public/metamask2.png' alt="screen" /> | ||
|
||
</p> | ||
|
||
|
||
run the command to start the app: | ||
```bash | ||
# from examples/erc20-react-example | ||
yarn start | ||
``` | ||
and then you can open your browser on http://localhost:3001 | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
ERC20PresetMinterPauser__factory | ||
} from '@buildwithsygma/sygma-contracts'; | ||
import { utils, BigNumber, ethers } from 'ethers'; | ||
|
||
async function mintERC20() { | ||
const provider = new ethers.providers.JsonRpcProvider('http://localhost:8547'); | ||
const wallet = ethers.Wallet.fromMnemonic('black toward wish jar twin produce remember fluid always confirm bacon slush', "m/44'/60'/0'/0/0") | ||
console.log('wallet address: ', wallet.address) | ||
console.log('wallet private key: ', wallet.privateKey) | ||
const signer = wallet.connect(provider); | ||
|
||
const tokenContract = ERC20PresetMinterPauser__factory.connect( | ||
'0x1CcB4231f2ff299E1E049De76F0a1D2B415C563A', | ||
signer, | ||
); | ||
// console.log("🚀 ~ file: feeOracle.ts ~ line 172 ~ testFeeOracle ~ tokenContract", tokenContract) | ||
const mintTx = await tokenContract.mint(wallet.address, ethers.utils.parseUnits("99.0", 18) ) | ||
await mintTx.wait(1) | ||
const balance = await tokenContract.balanceOf(wallet.address); | ||
console.log('🚀 ~ file: feeOracle.ts ~ line 174 ~ testFeeOracle ~ balance', balance); | ||
const balanceFormatted = ethers.utils.formatUnits(balance, 18); | ||
console.log( | ||
'🚀 ~ file: feeOracle.ts ~ line 175 ~ testFeeOracle ~ balanceFormatted', | ||
balanceFormatted, | ||
); | ||
} | ||
mintERC20(); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.