|
|
пре 3 година | |
|---|---|---|
| .. | ||
| contracts | b4c8f2e470 Refactor our CW contract + cleanups (#262) | пре 3 година |
| devnet | 07bf9dbee2 Abehjati/use-cw-1-for-contracts (#240) | пре 3 година |
| tools | b4c8f2e470 Refactor our CW contract + cleanups (#262) | пре 3 година |
| .dockerignore | 59ac319305 Abehjati/rename-terra-to-cw (#239) | пре 3 година |
| .gitignore | 59ac319305 Abehjati/rename-terra-to-cw (#239) | пре 3 година |
| Cargo.lock | b4c8f2e470 Refactor our CW contract + cleanups (#262) | пре 3 година |
| Cargo.toml | b4c8f2e470 Refactor our CW contract + cleanups (#262) | пре 3 година |
| Dockerfile.build | 59ac319305 Abehjati/rename-terra-to-cw (#239) | пре 3 година |
| README.md | b4c8f2e470 Refactor our CW contract + cleanups (#262) | пре 3 година |
| build.sh | 59ac319305 Abehjati/rename-terra-to-cw (#239) | пре 3 година |
| rustfmt.toml | 59ac319305 Abehjati/rename-terra-to-cw (#239) | пре 3 година |
This directory contains The Pyth contract on CosmWasm and utilities to deploy it in CosmWasm chains.
Deploying the CosmWasm contract has two steps:
This directory includes a script to perform both steps. Read below for the details.
First, build the contracts within the current directory:
bash build.sh
This command will build and save the Pyth contract in the artifact directory.
Then, to deploy the Pyth contract (pyth_cosmwasm.wasm), run the following command in the tools directory:
npm ci # Do it only once to install the required packages
npm run deploy-pyth -- --network testnet --artifact ../artifacts/pyth_cosmwasm.wasm --mnemonic "..."
If successful, this command will print something along the lines of:
Storing WASM: ../artifacts/pyth_cosmwasm.wasm (367689 bytes)
Deploy fee: 88446uluna
Code ID: 2435
If you do not pass any additional arguments to the script, it will only upload the code and return the code id. If you want to create a new contract or upgrade an existing contract you should pass more arguments that are described below.
If you want to instantiate a new contract after your deployment, pass --instantiate to the above command.
This command will upload the code and instantiates a new Pyth contract with the resulting code id:
npm run deploy-pyth -- --network testnet --artifact ../artifacts/pyth_cosmwasm.wasm --mnemonic "..." --instantiate
If successful, the output should look like so:
Storing WASM: ../artifacts/pyth_cosmwasm.wasm (183749 bytes)
Deploy fee: 44682uluna
Code ID: 53199
Instantiating a contract
Sleeping for 10 seconds for store transaction to finalize.
Instantiated Pyth at terra123456789yelw23uh22nadqlyjvtl7s5527er97 (0x0000000000000000000000001234567896267ee5479752a7d683e49317ff4294)
Deployed Pyth contract at terra123456789yelw23uh22nadqlyjvtl7s5527er97
If you want to upgrade an existing contract pass --migrate --contract terra123456xyzqwe.. to the above command.
This command will upload the code, and with the resulting code id, will migrate the existing contract to the new one:
npm run deploy-pyth -- --network testnet --artifact ../artifacts/pyth_cosmwasm.wasm --mnemonic "..." --migrate --contract "terra123..."
If successful, the output should look like so:
Storing WASM: ../artifacts/pyth_cosmwasm.wasm (183749 bytes)
Deploy fee: 44682uluna
Code ID: 53227
Sleeping for 10 seconds for store transaction to finalize.
Migrating contract terra1rhjej5gkyelw23uh22nadqlyjvtl7s5527er97 to 53227
Contract terra1rhjej5gkyelw23uh22nadqlyjvtl7s5527er97 code_id successfully updated to 53227
While running the instantiation/migration commands you might get the following errors:
You can rerun your command if you encounter any of the above errors. If an error occurs after the new code is uploaded, you can avoid re-uploading the code and use the uploaded code for instantiation/migration. You can use the printed code id in the logs
by passing --code-id <codeId> instead of --artifact. If you do so, the script will skip uploading the code and instantiate/migrate the contract with the given code id.
An example command using an existing code id looks like so:
npm run deploy-pyth -- --network testnet --code-id 50123 --mnemonic "..." --migrate --contract "terra123..."