Skip to content

Latest commit

 

History

History
105 lines (68 loc) · 2.45 KB

README.md

File metadata and controls

105 lines (68 loc) · 2.45 KB

soroban-examples

Example contracts for Soroban using smartdeploy.

First need to install the binaries locally:

cargo install soroban-cli --version 20.0.0-rc4 --root target --debug
cargo install smartdeploy-cli --version 0.4.2 --root target --debug

create a new testnet account

./target/bin/soroban config identity generate test_smartdeploy --network testnet

Next change into a project:

e.g.

cd hello_world
cargo add smartdeploy-sdk

Add the following line to a src/lib.rs:

smartdeploy_sdk::core_riff!();

Build:

make

Publish

This calls smartdeploy's contract with the call subcommand to call the publish contract method. "contract_name" is the name of the published contract.

../target/bin/smartdeploy call smartdeploy --fee 10000 --source test_smartdeploy -- publish --contract_name hello_test1 --author test_smartdeploy --wasm-file-path ./target/wasm32-unknown-unknown/release/soroban_hello_world_contract.wasm

Deploy

../target/bin/smartdeploy deploy --deployed-name hello_test_contract --published-name hello_test

Note, if your contract needs initialization you can add -- --help, to see the list of possible methods you can invoke when deploying.

Call

../target/bin/smartdeploy call hell_test_contract -- hello --to world

Possible contract errors:

#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[repr(u32)]
pub enum Error {
    /// No such Contract has been published
    NoSuchContractPublished = 1,
    /// No such version of the contact has been published
    NoSuchVersion = 2,
    /// Contract already published
    AlreadyPublished = 3,

    /// No such contract deployed
    NoSuchContractDeployed = 4,

    /// Contract already deployed
    AlreadyDeployed = 5,

    /// Contract already claimed
    AlreadyClaimed = 6,

    /// Failed to initialize contract
    InitFailed = 7,
}

Follow along with The Documentation.

Open a development environment on GitPod:

Open in Gitpod

WARNING: These implementations have not been tested or audited. They are likely to have significant errors and security vulnerabilities. They should not be relied on for any purpose.

Join us In the Stellar Developers Discord server