Skip to main content
This is a simple example using the Stellar SDK to create, simulate, and then assemble a Stellar transaction which invokes an increment function of the auth example contract.
Please go to the project homepage of JavaScript SDK to learn how to install it.
First, upload the bytes of the example contract onto the blockchain using Stellar CLI. This is called “install” because, from the perspective of the blockchain itself, this contract has been installed.
This will return a hash; save that, you’ll use it soon. For this example, we will use bc7d436bab44815c03956b344dc814fac3ef60e9aca34c3a0dfe358fcef7527f.No contract has yet been deployed with this hash. In Soroban, you can have many Smart Contracts which all reference the same Wasm hash, defining their behavior. We’ll do that from the following JavaScript code itself.
Client from existing ContractIf you don’t need to deploy a contract, and instead already know a deployed contract’s ID, you can instantiate a Client for it directly. This uses similar arguments to the ones to Client.deploy above, with the addition of contractId:
Now that we instantiated a client, we can use it to call methods on the contract. Picking up where we left off: