Controlling Smart Contract Costs

Loom Network
3 min readSep 14, 2020

--

Photo by Max Titov on Unsplash

Once the next major version of the Loom protocol goes live developers will have to deposit LOOM tokens on Basechain to cover the cost of transactions sent by users of their dapps. Every time a user sends a transaction to Basechain to interact with a smart contract a fee will be charged to cover the cost of processing the transaction and including it in the blockchain. In this article we’ll clarify who is responsible for paying transaction fees in various scenarios, and we’ll also introduce the system that will allow developers to control the costs incurred by the smart contracts they deploy to Basechain.

Transaction Fees

Blockchains built using the Loom protocol run two kinds of smart contracts. Built-in smart contracts and third-party smart contracts. The former are implemented by Loom Network, and provide core functionality like DPoS and on-chain LOOM transfers, while the latter are implemented by dapp developers. A user can call (i.e. modify the state of) both built-in and third-party contracts via signed transactions sent to a Loom protocol based network. The account from which the transaction fee is deducted depends on the type of smart contract that transaction calls.

If a user submits a transaction to the network that calls a built-in contract then the transaction fee is deducted from the user’s account. However, if a user submits a transaction that calls a third-party contract the transaction fee is deducted from the account of the developer that deployed that smart contract. If the account from which the transaction fee is deducted doesn’t have enough LOOM available to pay the fee then the transaction will be rejected, and will need to be resubmitted once the account is topped up.

In the event that a user submits a transaction that calls a contract which then itself calls another contract (or multiple other contracts) the transaction fee is deducted from the account of the developer of the first contract in the call chain.

User Tiers

Developers will be able to create a limited number of tiers to which they can assign users, those tiers can then be associated with smart contracts deployed by the developers. For each tier a developer can specify the rate at which calls can be made to a smart contract, and the maximum number of calls to a smart contract that should be allowed per user within a specific time period. These user tiers will allow developers to throttle and cap the running costs of their smart contracts.

If a user attempts to send a transaction that calls a smart contract that has no tier specified for that user then the transaction will be rejected by the network, and will not be included in the blockchain.

For testing purposes developers will be able to create and edit user tiers via a web UI integrated into the Basechain dashboard. While the web UI will provide a quick and easy way to tweak tiers we expect that most developers will configure their user tiers directly through the client APIs that will be provided for that purpose.

Business Models

With the introduction of transaction fees on Basechain third-party developers will have to come up with new sustainable business models that don’t rely on free compute and storage. We expect most developers will use subscription or usage fees collected from their users to purchase LOOM in order to maintain the positive LOOM balance required to keep their smart contracts operational.

To help developers build profitable dapps we’ll be building out new reporting capabilities to track monthly smart contract costs. These reports will be available via the Basechain dashboard and through client APIs.

--

--

Loom Network
Loom Network

Written by Loom Network

We’re building an ecosystem of blockchains to sustain the next generation of DeFi protocols, NFTs, and high-performance multi chain dapps.

No responses yet