Skip to content

Commit

Permalink
expand gas and allowance explanations (#1503)
Browse files Browse the repository at this point in the history
* expand gas and allowance explanations

* revert unwanted autoformat change

* Update docs/build/isc/v1.0.0-rc.6/docs/explanations/invocation.md

Co-authored-by: Lucas Tortora <[email protected]>

---------

Co-authored-by: Dr-Electron <[email protected]>
  • Loading branch information
lucas-tortora and Dr-Electron authored Mar 4, 2024
1 parent 5de50e6 commit e1045c8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions docs/build/isc/v1.0.0-rc.6/docs/explanations/invocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ This is called _asynchronous composability_.
## Gas

Gas expresses the "cost" of running a request in a chain. Each operation (arithmetics, write to disk, dispatch events,
etc.) has an associated gas cost.
etc.) has an associated gas cost. The amount of gas required for a transaction depends on the complexity of the
operation. For example, simple transfers may require less gas, while interacting with smart contracts for actions such
as token swaps can require more due to the higher computational work involved.

For users to specify how much they're willing to pay for a request, they need to specify a `GasBudget` in the request.
This gas budget is the "maximum operations that this request can execute" and will be charged as a fee based on the
Expand All @@ -84,10 +86,16 @@ The funds to cover the gas used will be charged directly from the user's on-chai

## Allowance

Any funds sent to the chain via on-ledger requests are credited to the sender's account.
An allowance is a feature within smart contracts that controls how much one address can spend on behalf
of another address. Before a third party can withdraw tokens from your account, you must explicitly set an allowance for
that third party's address, specifying the maximum amount of tokens they are allowed to transfer. This mechanism is used
in various decentralized finance (DeFi) applications, where you might allow a smart contract to interact with your
tokens to participate in staking, lending, or trading activities. The original token owner can adjust or revoke the
allowance at any time, providing control over how your tokens are used by others.

For contracts to use funds owned by the _caller_, the _caller_ must specify an `Allowance` in the request. Contracts can
then claim any of the allowed funds using the sandbox `TransferAllowedFunds` function.
Any funds sent to the chain via on-ledger requests are credited to the sender's account. If you want a contract to use
those funds, you must specify an `Allowance` in the request. Contracts can then claim any of the allowed funds using
the sandbox `TransferAllowedFunds` function.

The Allowance property looks like the following:

Expand Down

0 comments on commit e1045c8

Please sign in to comment.