Skip to main content

Tokens and the UTXO Ledger

Goshimmer implements the IOTA UTXO Ledger, a distributed ledger of tokens. The specification of the UTXO Ledger is not the target of this documentation (you can find more information in the Goshimmer documentation). You only need to know that the UTXO Ledger contains balances of colored tokens locked in addresses, like the following:

Address: Yk85765qdrwheQ4udj6RihxtPxudTSWF9qYe4NsAfp6K
IOTA: 1000
Red: 15
Green: 200

Where IOTA is the color code of IOTA tokens and Red and Green are other color codes (color codes are 32-byte hashes, as defined by Goshimmer). You can only move tokens on the UTXO Ledger by unlocking the corresponding address with its private key.

(In this tutorial we will use private key, signature scheme and wallet as synonyms).

The Solo environment implements a detailed in-memory UTXO Ledger. For example, you can only move tokens in the Solo environment by creating and submitting valid and signed transactions. You can also create new wallets on the UTXO Ledger and request iotas from the faucet to your wallet, as shown in the following example:

func TestTutorial2(t *testing.T) {
env := solo.New(t, false, false, seed)
_, userAddress := env.NewKeyPairWithFunds(env.NewSeedFromIndex(1))
t.Logf("address of the userWallet is: %s", userAddress.Base58())
numIotas := env.GetAddressBalance(userAddress, colored.IOTA) // how many iotas the address contains
t.Logf("balance of the userWallet is: %d iota", numIotas)
env.AssertAddressBalance(userAddress, colored.IOTA, utxodb.FundsFromFaucetAmount)

The deterministic output of the test:

=== RUN   TestTutorial2
53:47.437253000 INFO TestTutorial2.db dbmanager/dbmanager.go:54 creating new registry database. Persistent: false
53:47.438906800 INFO TestTutorial2 solo/solo.go:166 Solo environment has been created with initial logical time 00:01.000000000
tutorial_test.go:39: address of the userWallet is: 1Haybtqv1SdB8SWTKpWLLuREXf3q7uRePBoVCEMZnCHJF
tutorial_test.go:41: balance of the userWallet is: 1000000 iota
--- PASS: TestTutorial2 (0.00s)

The UTXO Ledger in Solo "lives" in the global environment env of the test. It is shared among all chains which are deployed on that environment. It serves as a medium for transactions between smart contracts on different chains. This way Solo makes it possible to test transacting between chains.

Note that in the test above we did not deploy any chains: the UTXO Ledger exists independently of any chains.