Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/scrtlabs/secret-template

Quickstart template to get started writing your own cosmwasm contracts
https://github.com/scrtlabs/secret-template

Last synced: 8 days ago
JSON representation

Quickstart template to get started writing your own cosmwasm contracts

Lists

README

        

# Secret Contracts Starter Pack

This is a template to build secret contracts in Rust to run in
[Secret Network](https://github.com/enigmampc/SecretNetwork).
To understand the framework better, please read the overview in the
[CosmWasm repo](https://github.com/CosmWasm/cosmwasm/blob/master/README.md),
and dig into the [CosmWasm docs](https://book.cosmwasm.com/).
This assumes you understand the theory and just want to get coding.

## Creating a new repo from template

Assuming you have a recent version of rust and cargo installed (via [rustup](https://rustup.rs/)),
then the following should get you a new repo to start a contract:

First, install
[cargo-generate](https://github.com/ashleygwilliams/cargo-generate).
Unless you did that before, run this line now:

```sh
cargo install cargo-generate --features vendored-openssl
```

Now, use it to create your new contract.
Go to the folder in which you want to place it and run:

```sh
cargo generate --git https://github.com/scrtlabs/secret-template.git --name YOUR_NAME_HERE
```

You will now have a new folder called `YOUR_NAME_HERE` (I hope you changed that to something else)
containing a simple working contract and build system that you can customize.

Don't forget to change the `name` and the `authors` fields in the `Cargo.toml` file.

## Create a Repo

After generating, you have a initialized local git repo, but no commits, and no remote.
Go to a server (eg. github) and create a new upstream repo (called `YOUR-GIT-URL` below).
Then run the following:

```sh
# this is needed to create a valid Cargo.lock file (see below)
cargo check
git checkout -b master # in case you generate from non-master
git add .
git commit -m 'Initial Commit'
git remote add origin YOUR-GIT-URL
git push -u origin master
```

## Using your project

Once you have your custom repo, you should check out [Developing](./Developing.md) to explain
more on how to run tests and develop code. Or go through the
[Getting Started docs](https://docs.scrt.network/secret-network-documentation/development/getting-started) to get a better feel
of how to develop.

[Publishing](./Publishing.md) contains useful information on how to publish your contract
to the world, once you are ready to deploy it on a running blockchain. And
[Importing](./Importing.md) contains information about pulling in other contracts or crates
that have been published.

You can also find lots of useful recipes in the `Makefile` which you can use
if you have `make` installed (very recommended. at least check them out).

Please replace this README file with information about your specific project. You can keep
the `Developing.md` and `Publishing.md` files as useful referenced, but please set some
proper description in the README.

## Importing Additional Dependencies

If you would like to import additional dependencies, such as [Secret Toolkit](https://github.com/scrtlabs/secret-toolkit) or cw-storage-plus, you can do so by adding the following to your cargo.toml file:

```sh
[dependencies]
secret-toolkit = { git = "https://github.com/scrtlabs/secret-toolkit", tag = "v0.8.0"}
cw-storage-plus = {version = "1.0.1", default-features = false}
```