Skip to main content

Deploy to a Local Network

If you have Docker installed, you can run a local standalone network with the Stellar Quickstart Docker image.

The Quickstart image is a single container that runs everything you need to test against a fully featured network. It contains:

  • Stellar Core – Node software that runs the network, coordinates consensus, and finalizes ledgers.
  • Soroban RPC server – JSON RPC server for interacting with Soroban contracts.
  • Horizon server – HTTP API for access ledger state and historical transactions.
  • Friendbot server – HTTP API for creating and funding new accounts on test networks.
info

It's also possible to run a contract in the local sandbox environment without a network using just the soroban-cli. See Run on Sandbox for more details.

To run a local standalone network with the Stellar Quickstart Docker image, run the following command.

docker run --rm -it \
--platform linux/amd64 \
-p 8000:8000 \
--name stellar \
stellar/quickstart:[email protected]:0993d3350148af6ffeab5dc8f0b835236b28dade6dcae77ff8a09317162f768d \
--standalone \
--enable-soroban-rpc

Once the image is started you can check its status by querying the Horizon API:

curl http://localhost:8000

Generate a key for use on the local sandbox environment by going to the Stellar Laboratory. Make note of both the G... and S... keys. The G... key is the public key and will also be the account ID. The S... key is the secret key and is that you use to control the account.

tip

It's a good practice to never use the same keys for testing and development that you use do for the public Stellar network. Generate new keys for testing and development and avoid ever using them for other purposes.

Create an account on the local sandbox environment by making a request to the local Friendbot. Specify as the addr the G... key of your account.

curl "http://localhost:8000/friendbot?addr=G..."

Once you have an account on the network, we'll use the code we wrote in Write a Contract and the resulting .wasm file we built in Build as our contract to deploy. Run the following commands to deploy the contract to the network. Use the S... key as the secret key.

soroban deploy \
--wasm target/wasm32-unknown-unknown/release/[project-name].wasm \
--secret-key S... \
--rpc-url http://localhost:8000/soroban/rpc \
--network-passphrase 'Standalone Network ; February 2017'
tip

It's good practice to avoid entering secret keys on the command line. You can also specify the secret key by setting the environment variable SOROBAN_SECRET_KEY. The soroban-cli is still in development and in the future there will be other secure ways to provide a secret key, such as via hardware keys.

A contract ID will be outputted.

cd4dae2c409c433b1e1d83994a20214d3e5f60bdd3a817978d8aa7c797864313

Using the contract ID that was outputted, use the soroban-cli to invoke the hello function with a single argument friend.

soroban invoke \
--id cd4dae2c409c433b1e1d83994a20214d3e5f60bdd3a817978d8aa7c797864313 \
--secret-key S... \
--rpc-url http://localhost:8000/soroban/rpc \
--network-passphrase 'Standalone Network ; February 2017' \
--fn hello \
--arg friend

The following output should appear.

["Hello","friend"]