WebSorobandocs v1
Open IDE

Docs

Invoke

Call contract functions with typed inputs, the full ScType entry reference, read vs signed writes, and how to read results.


Invoke calls a function on a deployed contract. WebSoroban reads the contract's spec and renders a typed form: one field per argument, each validated for its Soroban type. You enter plain values, 123, true, a G… address, and WebSoroban encodes them to ScVal for you.

Open the Invoke panel (the contract console) on a deployed contract, pick a function, fill the fields, and run. Invoke is network-aware: read calls simulate free on either network; a mainnet write shows its fee, asks you to confirm, and is signed by your connected wallet in the browser (or the custodial opt-in). See Networks.

Read vs write#

Every call is simulated first. What happens next depends on whether the function changes state.

  • read-only A function that only reads storage is a read. Click Run (simulate). Nothing is signed or submitted; the return value comes back immediately and costs nothing.
  • signed A function that writes storage or requires authorization is a write. WebSoroban shows the simulated result first, then you click Invoke & sign to sign with your wallet and submit the transaction.

WebSoroban decides read vs write from the simulation's footprint and auth, you don't mark a function as one or the other.

Writes cost a fee

A signed write pays a resource fee in stroops from your testnet wallet. If the balance is too low the call fails; refund from the faucet and retry.

Entering each Soroban type#

The form picks an input control from the argument's ScType. Enter values exactly as below, WebSoroban converts the string you type into the right ScVal.

ScTypeControlWhat you typeExample
booltoggleon / offtrue
u32, i32numberan integer123
u64, i64, u128, i128, u256, i256numberan integer (sent as a big integer)1000000000
Timepoint, Durationnumberan integer (seconds)1700000000
Symboltextup to 32 chars, [a-zA-Z0-9_]increment
Stringtextany UTF-8 texthello world
Addresstexta G… account or C… contract idGADTEST… / CDLZ…
Bytestexthex, even length, optional 0xdeadbeef
BytesN<32>texthex of exactly N bytes (2N hex chars)a 64-char hex string
Option<T>field for Tleave empty for None, else enter Tempty → None
Vec<T>texta JSON array[1, 2, 3]
Map<K,V>texta JSON object{ "a": 1 }
tuple / struct / enumtextJSON matching the shape{ "Active": {} }

Rules that catch people out:

  • Integers go in as digits, never quoted. u32 becomes a JS number; 64-bit and wider types become big integers. Non-numeric input for a number field is rejected before the call.
  • Address accepts both a G… account and a C… contract id, both are valid Soroban addresses.
  • Bytes must be even-length hex. BytesN<32> must be exactly 32 bytes (64 hex chars); the field tells you if the length is wrong.
  • Option<T> left empty is None. Type a value to send Some(value).
  • Composite types are JSON. A Vec<u32> is [1, 2, 3]; an enum variant is its JSON object form.

Worked example#

A transfer(from: Address, to: Address, amount: i128) on a token contract:

from    GADTEST...XYZ        (Address)
to      GBQRST...UVW         (Address)
amount  500000000           (i128)

transfer requires the sender's authorization, so it's a write. Click Invoke & sign; the wallet signs and the transaction submits.

Reading the result#

The result panel shows:

  • status, simulated for a read, success for a confirmed write.
  • return value, decoded to JSON using the contract spec. A u32 comes back as a number, an Address as its string form, a struct as an object.
  • resource fee, the fee paid, in stroops (writes only).
  • tx hash, for a confirmed write, with a link to stellar.expert. Reads have no hash.
  • events, any contract events emitted, decoded.
{ "status": "simulated", "returnValue": 2 }
{
  "status": "success",
  "returnValue": 3,
  "resourceFee": "00",
  "txHash": "a1b2c3…"
}

When it fails#

Errors are returned in plain language, not raw XDR:

MessageCauseFix
Contract returned error #NThe contract's own error enumCheck that error code in your contract
Authorization failedA write needs a signature it didn't getConfirm the call signs with the right account
Insufficient balance to cover the resource feeWallet too lowFund from the faucet and retry
Storage footprint is expired/archivedContract state needs restoringRestore the entry, then retry
Invalid arguments for <fn>: …A field doesn't match its ScTypeRe-check the type in the table above

A failed read or write is saved to your invocation history with the humanized error, so you can see what happened without re-running it.

Saved function tests#

Any call you run can be saved as a function test with an expected result, WebSoroban replays it by simulation and checks the return. See Test.

Next#

  • Run unit and integration tests in Test.
  • See the full type glossary in Reference.