Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 42 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,77 @@
# Sei-Cosmwasm Package

This repository contains the sei-cosmwasm package to support smart contract querying and messages to the modules in sei-chain. It also includes an example contract that can be used to test package behavior locally and can be used as a reference for implementation details to include sei-chain integration in your smart contracts.
## Introduction

The sei-cosmwasm package is a comprehensive toolkit designed for developers looking to integrate sei-chain functionalities into their Cosmos smart contracts. Leveraging the power of CosmWasm, this package simplifies the process of querying blockchain state and sending messages to sei-chain modules directly from your smart contracts. Whether you're building complex DeFi platforms or simple token contracts, sei-cosmwasm offers the building blocks necessary for seamless integration.

## Prerequisites

Before you begin, ensure you have the following installed and configured:

- Docker: For building and deploying contracts.
- Rust: Latest stable version.
- Sei-chain CLI (seid): For interacting with the sei-chain network.

A basic understanding of smart contract development and the Cosmos SDK will also be beneficial.

## Build Sei Tester Contract

To build the sei tester contract, run the following command:

```shell
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.14.0
```

This command uses the `cosmwasm/rust-optimizer:0.14.0` Docker image to compile your smart contracts, ensuring a consistent and optimized build environment.

## Testing with LocalSei

### Store Contract Code

Store your wasm contract on the blockchain:

```shell
seid tx wasm store artifacts/sei_tester.wasm -y --from <account> --chain-id <name> -b block --gas=3000000 --fees=1000sei
```

Make sure to note the code ID for the contract from the tx response. You can also find it in the list of uploaded code with this query:
- `<account>`: Your sei-chain account name.
- `<name>`: The chain ID of your local sei-chain instance.

```shell
seid q wasm list-code
```
After storing, note the code ID from the transaction response.

### Instantiate Contract

Deploy your contract with:

```shell
seid tx wasm instantiate <code-id> '{}' -y --no-admin --from <account> --chain-id <name> --gas=1500000 --fees=1000sei -b block --label sei-tester
```

Make sure to note the contract address for the contract from the tx response. You can also find it with this query:

```shell
seid q wasm list-contract-by-code <code-id>
```
Replace `<code-id>` with the ID obtained in the previous step.

### Query Smart Contract

Interact with your contract:

```shell
seid q wasm contract-state smart <contract-address> <json-query-literal>
seid q wasm contract-state smart <contract-address> '{"exchange_rates": {}}'
```

The json literal may look something like this:
- `<contract-address>`: The address of your instantiated contract.

```json
'{"exchange_rates": {}}'
```
This query fetches exchange rates, as an example. Adjust the JSON query literal based on the data you wish to query.

## Additional Resources

For more detailed technical documentation, visit our [Developer Guides](https://docs.sei.io/develop/get-started). Join our community on [Discord](https://discord.gg/sei) for support and discussions.

## Changelog

For a detailed list of changes and updates, refer to our [CHANGELOG.md](#).

## Contributing

We welcome contributions from the community! If you're interested in improving the sei-cosmwasm package, please review our [contribution guidelines](#) for information on submitting pull requests and reporting bugs.