How can contracts hold balances if they can't hold UTXOs?

Take the two following docs references:

https://fuellabs.github.io/sway/v0.45.0/book/reference/solidity_differences.html?highlight=utxo#account-types

https://fuelbook.fuel.network/v1.1.0/vs-evm.html?highlight=contract%20utxo#fuelvm-has-multiple-native-assets

In the first link, it is said that:

The other wrapper, ContractId , reflects that of a deployed contract in the EVM but cannot hold UTXOs.

Whereas in the second link, it is said that:

In Fuel, any contract can mint its UTXO-based native asset using a set of easy asset opcodes.

These two statements seem contradictory to me. But in any case, I’m interested to know how can contracts hold asset balances if they can’t hold UTXOs?

It would be helpful to provide a diagram similar to the one that depicts UTXO dependency.

You caught an interesting distinction: Fuel assets stop being UTXOs when they’re sent to a smart contract.

Smart contracts basically implement an “accounts model”, with token balances stored as integers, not UTXOs.

This is important for smart contracts, which need to be able to read token balances. For example, an AMM pool needs to look at the balances of both assets to determine the price, and this wouldn’t be feasibly possible if the contract had to add up an arbitrary amount of UTXOs.

Regarding the second quote:

In Fuel, any contract can mint its UTXO-based native asset using a set of easy asset opcodes.

This is referring to a contract being able to mint assets, not own assets. Technically, that quote is a little bit incorrect, since assets are first minted to a contract’s balance, and only become UTXOs when they’re transferred to an output address.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.