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

Commit

Permalink
Merge pull request #1239 from EspressoSystems/arbitrum-goerli-prepara…
Browse files Browse the repository at this point in the history
…tions

Arbitrum goerli preparations
  • Loading branch information
sveitser authored Nov 30, 2022
2 parents ce8bada + 2baae46 commit 58542ed
Show file tree
Hide file tree
Showing 12 changed files with 1,640 additions and 24 deletions.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ describes the project at a high level.
- [Testnets](#testnets)
- [Goerli](#goerli)
- [Running the smoke tests](#running-the-smoke-tests)
- [Arbitrum on Goerli](#arbitrum-on-goerli)

## Obtaining the source code

Expand Down Expand Up @@ -599,9 +600,14 @@ generator to authenticate itself in various ways:
assets in the official asset library.

You must also have a TOML file specifying the assets to create. There are already TOML files for
the official asset libraries for [the Goerli deployment](wallet/official_assets/cape_v1_official_assets.toml)
and [the local demo](wallet/official_assets/cape_demo_local_official_assets.toml). These can always
be modified or copied to create fully customizable asset libraries.
the official asset libraries for

- [the Goerli deployment](wallet/official_assets/cape_v1_official_assets.toml)
- [the local demo](wallet/official_assets/cape_demo_local_official_assets.toml)
- [the Arbitrum goerli deployment](wallet/official_assets/cape_v2_official_assets.toml)

These can always be modified or copied to create fully customizable asset
libraries.

Then, the command would look like

Expand Down Expand Up @@ -705,3 +711,17 @@ project and use their arbitrum goerli RPC and use it via
```
CAPE_WEB3_PROVIDER_URL=https://arbitrum-goerli.infura.io/v3/... run-tests-arbitrum
```

To deploy mintable tokens that users can mint by sending Ether to it run

```
hardhat deploy --tags Token --network arbitrum_goerli --reset
```

The currently deployed token contracts on arbitrum goerli are

```console
WETH 0x4F1D9E040cf28A522ec79951cDb7B55c8aE4744E
DAI 0xBeec50ed16E3559afCD582cC98ed2b5F5DcA189E
USDC 0x9A4f4Ee35a8FfEE459B3187A372d422790fc8aAB
```
5 changes: 4 additions & 1 deletion contracts/contracts/SimpleToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ pragma solidity ^0.8.0;
import "./WrapToken.sol";

contract SimpleToken is WrapToken {
constructor() WrapToken("Simple Token", "SIT") {}
/// @notice The deployer receives 1e9 units.
constructor() WrapToken("Simple Token", "SIT") {
_mint(msg.sender, 1_000_000_000);
}
}
4 changes: 4 additions & 0 deletions contracts/contracts/USDC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ import "./WrapToken.sol";

contract USDC is WrapToken {
constructor() WrapToken("USD Coin", "USDC") {}

function decimals() public pure override returns (uint8) {
return 6;
}
}
16 changes: 5 additions & 11 deletions contracts/contracts/WrapToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,18 @@ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

/// @notice This token is only intended to be used for testing.
contract WrapToken is ERC20 {
/// @notice The caller of this method receives 1000*10**6 units.
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
_mint(msg.sender, 1000 * 10**6);
}
constructor(string memory name, string memory symbol) ERC20(name, symbol) {}

/// @notice Allows minting tokens by sending Ether to it.
receive() external payable {
_mint(msg.sender, 10**6 * msg.value);
}

function decimals() public view virtual override returns (uint8) {
return 6;
uint256 amount = msg.value / 10**(18 - decimals());
_mint(msg.sender, amount);
}

function withdraw() external payable {
function withdraw() external {
uint256 balance = balanceOf(msg.sender);
address payable sender = payable(msg.sender);
_burn(sender, balance);
sender.transfer(balance / 10**6);
sender.transfer(balance * 10**(18 - decimals()));
}
}
17 changes: 11 additions & 6 deletions contracts/deploy/10_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ import { DeployFunction } from "hardhat-deploy/types";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
const { tokenOwner } = await getNamedAccounts();
const { deploy, log, read, execute } = deployments;
const { deployer } = await getNamedAccounts();

await deploy("SimpleToken", { from: tokenOwner, log: true });
await deploy("WETH", { from: tokenOwner, log: true });
await deploy("DAI", { from: tokenOwner, log: true });
await deploy("USDC", { from: tokenOwner, log: true });
const deployToken = async (name: string) => {
await deploy(name, { from: deployer, log: true });
let decimals = await read(name, "decimals");
log(`Deployed with ${decimals} decimals`);
};

await deployToken("WETH");
await deployToken("DAI");
await deployToken("USDC");
};

export default func;
Expand Down
Loading

0 comments on commit 58542ed

Please sign in to comment.