Creates a bridge of SNT into Optimism
Go to file
r4bbit fe1a4e96ab
refactor: use custom error type instead of error strings (#18)
The `onlyBridge` modifier uses strings as error messages which are
expensive in gas.

This commit refactors this to use a custom error type instead and also
introduces some basic tests to ensure the errors are emitted properly.

It also adds some sanity tests for minting and burning bridge tokens.
2023-10-06 08:37:32 +02:00
.github refactor: move to foundry template 2023-09-26 16:58:36 +02:00
.vscode refactor: move to foundry template 2023-09-26 16:58:36 +02:00
contracts refactor: use custom error type instead of error strings (#18) 2023-10-06 08:37:32 +02:00
lib chore(deps): update minime dependency (#14) 2023-10-06 08:26:32 +02:00
script feat: introduce foundry deploy script (#17) 2023-10-06 08:27:03 +02:00
scripts add bridge code 2023-07-17 13:59:00 -03:00
test refactor: use custom error type instead of error strings (#18) 2023-10-06 08:37:32 +02:00
.editorconfig refactor: move to foundry template 2023-09-26 16:58:36 +02:00
.env.example refactor: move to foundry template 2023-09-26 16:58:36 +02:00
.gas-snapshot refactor: use custom error type instead of error strings (#18) 2023-10-06 08:37:32 +02:00
.gitattributes refactor: move to foundry template 2023-09-26 16:58:36 +02:00
.gitignore refactor: move to foundry template 2023-09-26 16:58:36 +02:00
.gitmodules refactor: move to foundry template 2023-09-26 16:58:36 +02:00
.prettierignore chore: prettier ignore `contracts.json` 2023-10-05 12:37:16 +02:00
.prettierrc.yml refactor: move to foundry template 2023-09-26 16:58:36 +02:00
.solhint.json refactor: move to foundry template 2023-09-26 16:58:36 +02:00
PROPERTIES.md refactor: move to foundry template 2023-09-26 16:58:36 +02:00
README.md refactor: move to foundry template 2023-09-26 16:58:36 +02:00
codecov.yml refactor: move to foundry template 2023-09-26 16:58:36 +02:00
contracts.json chore: prettier ignore `contracts.json` 2023-10-05 12:37:16 +02:00
foundry.toml refactor: move to foundry template 2023-09-26 16:58:36 +02:00
index.js add bridge code 2023-07-17 13:59:00 -03:00
package.json refactor: move to foundry template 2023-09-26 16:58:36 +02:00
pnpm-lock.yaml refactor: move to foundry template 2023-09-26 16:58:36 +02:00
remappings.txt refactor: move to foundry template 2023-09-26 16:58:36 +02:00
slither.config.json refactor: move to foundry template 2023-09-26 16:58:36 +02:00

README.md

Bridging SNT with the Optimism SDK

This repository contains code to deploy SNT in Ethereum and bridge it to optimism.

Scripts:

npx hardhat run scripts/deploySNT.js --network <network> -> deploy to Optimism chain with the contracts.json configured addresses.

npx hardhat run scripts/deployOptimism.js --network <network> -> deploy to an optimism chain with the contracts.json configured addresses.

The script node index.js uses the configured goerli bridge to bridge 1 STT on Goerli into 1 SNT on Optimism-Goerli.

To everything work, .env needs to be created out of .env.example.

All tokens, even on Optimism, are MiniMeToken variant, meaning they save all account's balance change on Ethereum state for democracy contract ballots. Learn more about MiniMeToken on the official repository Giveth/minime.

Differences from regular MiniMeToken

  1. There are 2 functions to mint/burn, one is mint() & generateTokens(), and other is burn() & destroyTokens(). One come from MiniMeToken inheritance, and other comes from IOptimismMintableERC20 inheritance. See more on point 2.
  2. MiniMeToken controller (SNTPlaceHolder) is also deployed on Optimism, and it could be replaced by another controller that could call generateToken function, potentially breaking the bridge, however, if we don't do this change, than it should be fine.
  3. MiniMeTokenFactory used in createCloneToken create new MiniMeTokens that are one inheritance down from OptimismMintableMiniMeToken, this is fine, just strange, but it couldnt be different, as clone tokens are not suppoused to be minted by bridge. This function is not even used by us.
  4. MiniMeToken version() had to be renamed to token_version() due a conflict on inheritance and requirements of Optimism. Semver inheritance uses version() and this seems a requirement for Optimism.