Soroban, the Stellar network’s smart contracts platform, is now integrated into Validation Cloud’s...
If building with a Unix-based system, the Rust toolchain and CLI can be installed like so:
If building with Windows, you can install rustup-init.exe to your system.
Note: Rustup is the preferred toolchain manager. Homebrew is an alternative manager on Unix machines, but it will cause more issues for a Soroban environment.
By this point, ensure that typing the “soroban” command on your terminal outputs the default response for CLI usage commands.
Next, you can configure your CLI for the Stellar Testnet:
2. Create Soroban Project & Identity
Once your CLI is configured, you can run the following command to quickly create a Rust workspace project, automatically structuring it in the recommended format:
The config.toml that gets auto-generated comes preconfigured to optimize for a maximum contract size of 64KB. Ethereum, by contrast, only has a maximum contract size of 24KB before it will run out of gas (excluding workarounds like “The Diamond Pattern").
3. Write the Smart Contract
Note the contract lib.rs located in your Soroban Project Directory at soroban-validationcloud > contracts > hello_world > src > lib.rs:
Additionally, find the above contract’s corresponding Cargo.toml file. Every contract should have its own Cargo.toml file that builds upon the top-level Cargo.toml at the root of the project directory.
To test your deployment environment, you can go straight to Step 4 to confirm you are able to get the above hello_world contract deployed to testnet. Or, you can create a new contract that incorporates a new functionality, like incrementing or decrementing some public variable, or transferring a balance from itself back to you.
4. Test the Contract
As you advance along your contract development journey, testing becomes as important, if not more important than the underlying contract development process.
While more thorough walkthroughs on testing will be performed later, for now you can activate the default test from initialization (located above, or at soroban-validationcloud > contracts > hello_world > src > test.rs) to understand what to expect:
The default test will compile up to nearly 200 items and should ultimately pass. You can experiment by altering certain values in the test to see what makes it fail, and what satisfies passing scores for your relevant use cases.
5. Build and Deploy
To deploy a Soroban contract on the testnet, it must first be built like so:
Once built, you can now deploy the contract!
The output should be a hash string that you can use to identify your deployment on the Soroban explorer.
More Soroban contract examples can be found here, and a Gitpod environment can also be spun up here to get started with an ephemeral working environment: https://gitpod.io/#https://github.com/stellar/soroban-examples
Start Building on Soroban
For developers seeking familiarity with high-performance blockchains, Soroban offers a compelling case. Its unique focus on specific markets, coupled with high-performance infrastructure and a developer-friendly approach through tools like Validation Cloud's Soroban RPC API, makes it an attractive platform for building the next generation of decentralized applications. Embrace the shift and explore what Soroban has to offer to your Web3 development journey.
About Validation Cloud
Validation Cloud is a Web3 data streaming and infrastructure company that connects organizations into Web3 through a fast, scalable, and intelligent platform. Headquartered in Zug, Switzerland, Validation Cloud offers highly performant and customizable products in staking, node, and data-as-a-service. Learn more at validationcloud.io | LinkedIn | X