diff --git a/docs/tutorials/write-a-contract.mdx b/docs/tutorials/write-a-contract.mdx index c0383a945..b6e48376c 100644 --- a/docs/tutorials/write-a-contract.mdx +++ b/docs/tutorials/write-a-contract.mdx @@ -16,7 +16,7 @@ well suited to being deployed into small programs like those deployed to blockchains. ```rust -use soroban_sdk::{contractimpl, vec, Env, Symbol, Vec}; +use soroban_sdk::{contractimpl, symbol, vec, Env, Symbol, Vec}; ``` The contract will need to import the types and macros that it needs from the @@ -26,13 +26,13 @@ how to setup a project. Many of the types available in typical Rust programs, such as `std::vec::Vec`, are not available, as there is no allocator and no heap memory in Soroban contracts. The `soroban-sdk` provides a variety of types like `Vec`, `Map`, -`BigInt`, `Binary`, `FixedBinary`, that all utilize the Soroban environment's -memory and native capabilities. +`BigInt`, `Bytes`, `BytesN`, `Symbol`, that all utilize the Soroban +environment's memory and native capabilities. ```rust pub struct Contract; -#[contractimpl(export_if = "export")] +#[contractimpl] impl Contract { pub fn hello(env: Env, to: Symbol) -> Vec { todo!() @@ -46,22 +46,18 @@ externally are should be marked with `pub` visibility. The first argument can be an `Env` argument to get a copy of the Soroban environment, which is necessary for most things. -Implementations annotated can be configured to export the contract functions -only if a feature is enabled, with `export_if = "[feature-name]"`. - Putting those pieces together a simple contract will look like this. ```rust title="src/lib.rs" #![no_std] -use soroban_sdk::{contractimpl, vec, Env, Symbol, Vec}; +use soroban_sdk::{contractimpl, symbol, vec, Env, Symbol, Vec}; pub struct Contract; -#[contractimpl(export_if = "export")] +#[contractimpl] impl Contract { pub fn hello(env: Env, to: Symbol) -> Vec { - const GREETING: Symbol = Symbol::from_str("Hello"); - vec![&env, GREETING, to] + vec![&env, symbol!("Hello"), to] } } ```