-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from skip-mev/jw/deploy-instructions
add deploy instructions for go fast gateway
- Loading branch information
Showing
6 changed files
with
198 additions
and
25 deletions.
There are no files selected for viewing
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,67 @@ | ||
# How to deploy the Go Fast contracts | ||
|
||
## Deploying the Cosmwasm contract | ||
|
||
### 1. Create a `.env` file in the `cosmwasm` directory with the following: | ||
|
||
``` | ||
DEPLOYER_MNEMONIC=<your_mnemonic> | ||
``` | ||
|
||
### 2. Store the contract: | ||
|
||
``` | ||
npx ts-node scripts/storeContract.ts | ||
``` | ||
|
||
### 3. Instantiate the contract: | ||
|
||
First, update the variables in `scripts/instantiateContract.ts` to match your configuration. | ||
|
||
Then, run the following command: | ||
|
||
``` | ||
npx ts-node scripts/instantiateContract.ts | ||
``` | ||
|
||
This script will output the contract address, as well as the hex representation of the contract address. Save this hex address for use later. | ||
|
||
## Deploying the Solidity contract | ||
|
||
### 1. Update `Deploy.s.sol` configuration. | ||
|
||
Most of the variables in `Deploy.s.sol` are constants and can be left as is. The only variable that you will need to update is `owner`. | ||
|
||
### 2. Deploy the contract. | ||
|
||
``` | ||
forge script ./script/Deploy.s.sol --rpc-url <RPC_URL> --private-key <PRIVATE_KEY> --broadcast | ||
``` | ||
|
||
## Setting the remote contract (EVM) | ||
|
||
In order to submit and settle orders you must make the Solidity contract aware of the Cosmwasm deployment. | ||
|
||
### 1. Update `SetRemote.s.sol` configuration. | ||
|
||
In `script/SetRemote.s.sol`, update the `remoteContract` variable with the hex address that was logged when the Cosmwasm contract was instantiated. (You'll have to remove the `0x` prefix from the address.) | ||
|
||
### 2. Set the remote contract. | ||
|
||
``` | ||
forge script ./script/SetRemote.s.sol --rpc-url <RPC_URL> --private-key <PRIVATE_KEY> --broadcast | ||
``` | ||
|
||
## Setting the remote contract (Cosmwasm) | ||
|
||
In order to fill orders and request settlements you must make the Cosmwasm contract aware of the Solidity contract. | ||
|
||
### 1. Update `setRemote.ts` configuration. | ||
|
||
In `cosmwasm/scripts/setRemote.ts`, update the `CONTRACT_ADDRESS` variable with the address of the deployed Solidity contract. | ||
|
||
### 2. Set the remote contract. | ||
|
||
``` | ||
npx ts-node cosmwasm/scripts/setRemote.ts | ||
``` |
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
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
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,75 @@ | ||
import "dotenv/config"; | ||
import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate"; | ||
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; | ||
import { calculateFee, GasPrice } from "@cosmjs/stargate"; | ||
import { padHex } from "viem"; | ||
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx"; | ||
|
||
const GAS_PRICE = GasPrice.fromString("0.025uosmo"); | ||
const CHAIN_PREFIX = "osmo"; | ||
const RPC_URL = "https://osmosis-rpc.polkachu.com"; | ||
|
||
const DOMAIN = 42161; | ||
const CONTRACT_ADDRESS = "0x23Cb6147E5600C23d1fb5543916D3D5457c9B54C"; | ||
|
||
interface MsgAddRemoteDomain { | ||
domain: number; | ||
address: string; | ||
} | ||
|
||
async function main() { | ||
const DEPLOYER_MNEMONIC = process.env.DEPLOYER_MNEMONIC; | ||
if (!DEPLOYER_MNEMONIC) { | ||
throw new Error("DEPLOYER_MNEMONIC is not set"); | ||
} | ||
|
||
const signer = await DirectSecp256k1HdWallet.fromMnemonic(DEPLOYER_MNEMONIC, { | ||
prefix: CHAIN_PREFIX, | ||
}); | ||
|
||
const accounts = await signer.getAccounts(); | ||
const signerAddress = accounts[0].address; | ||
|
||
const client = await SigningCosmWasmClient.connectWithSigner(RPC_URL, signer); | ||
|
||
const formattedContractAddress = padHex(CONTRACT_ADDRESS, { | ||
dir: "left", | ||
size: 32, | ||
}); | ||
|
||
const msgAddRemoteDomain: MsgAddRemoteDomain = { | ||
domain: DOMAIN, | ||
address: formattedContractAddress, | ||
}; | ||
|
||
const msg = { | ||
typeUrl: MsgExecuteContract.typeUrl, | ||
value: MsgExecuteContract.fromPartial({ | ||
sender: signerAddress, | ||
contract: CONTRACT_ADDRESS, | ||
msg: Buffer.from( | ||
JSON.stringify({ | ||
add_remote_domain: msgAddRemoteDomain, | ||
}) | ||
), | ||
}), | ||
}; | ||
|
||
const estimatedGas = await client.simulate(signerAddress, [msg], undefined); | ||
|
||
const fee = calculateFee( | ||
parseInt((estimatedGas * 1.5).toFixed(0)), | ||
GAS_PRICE | ||
); | ||
|
||
const tx = await client.signAndBroadcast( | ||
signerAddress, | ||
[msg], | ||
fee, | ||
undefined | ||
); | ||
|
||
console.log("Tx Hash:", tx.transactionHash); | ||
} | ||
|
||
main().catch(console.error); |
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,43 @@ | ||
import "dotenv/config"; | ||
import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate"; | ||
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; | ||
import { GasPrice } from "@cosmjs/stargate"; | ||
import { storeContract } from "./lib"; | ||
|
||
const GAS_PRICE = GasPrice.fromString("0.025uosmo"); | ||
const CHAIN_PREFIX = "osmo"; | ||
const RPC_URL = "https://osmosis-rpc.polkachu.com"; | ||
|
||
async function main() { | ||
const DEPLOYER_MNEMONIC = process.env.DEPLOYER_MNEMONIC; | ||
if (!DEPLOYER_MNEMONIC) { | ||
throw new Error("DEPLOYER_MNEMONIC is not set"); | ||
} | ||
|
||
const signer = await DirectSecp256k1HdWallet.fromMnemonic(DEPLOYER_MNEMONIC, { | ||
prefix: CHAIN_PREFIX, | ||
}); | ||
|
||
const accounts = await signer.getAccounts(); | ||
const signerAddress = accounts[0].address; | ||
|
||
console.log(`Signer Address: ${signerAddress}`); | ||
|
||
const client = await SigningCosmWasmClient.connectWithSigner(RPC_URL, signer); | ||
|
||
const { codeId } = await storeContract( | ||
client, | ||
signerAddress, | ||
"../artifacts/go_fast_transfer_cw-aarch64.wasm", | ||
GAS_PRICE | ||
); | ||
|
||
console.log(`Code ID: ${codeId}`); | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
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