Skip to content

Commit

Permalink
Merge branch 'master' into sns-asset-canister
Browse files Browse the repository at this point in the history
  • Loading branch information
jessiemongeon1 authored Jun 26, 2023
2 parents 865bb31 + 57bf7fe commit c9f8003
Show file tree
Hide file tree
Showing 37 changed files with 273 additions and 278 deletions.
27 changes: 8 additions & 19 deletions docs/developer-docs/gas-cost.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ The Internet Computer is a decentralized public utility, controlled by the NNS

Canister smart contract computations running on the Internet Computer blockchain are fueled by “cycles”, which play a similar role to “gas” on Ethereum. There are several major differences however. One of the most fundamental differences is that Ethereum leverages “user pays” and the Internet Computer and “smart contract pays” (sometimes called “reverse gas”) model. Whereas the Ethereum blockchain requires end users to send payments for the gas smart contracts consume with every transaction, on the Internet Computer, canister smart contracts are pre-charged with cycles, such that contracts effectively pay for their own computation - freeing users from the responsibility.

In late November 2022, high-replication application subnets have been made available on the Internet Computer. The first such subnets launch with a replication factor in the order of 30, different sizes may be available in the future. Cycles prices for the new high-replication subnets are scaled linearly based on the number of nodes from the base prices for 13-node subnets. The Bitcoin API is an exception to linear scaling, see the note below. The following tables provide pricing in cycles and USD for the 13-node baseline and the example of 34-node subnets. The linear scaling for a transaction is computed using the following formula, where *n* is the size of the subnet to compute the price for, **13_node_price** is the price for the transaction on the reference-size subnet with 13 nodes, and **DIV** is integer division:
In late November 2022, high-replication application subnets have been made available on the Internet Computer. The first such subnets launched with a replication factor in the order of 30, different sizes may become available in the future. Cycles prices for the new high-replication subnets are scaled linearly based on the number of nodes from the base prices for 13-node subnets. The pricing mechanics for the Bitcoin Mainnet API is slightly different, see the [Bitcoin API documentation](./integrations/bitcoin/bitcoin-how-it-works.md) for details.

The following tables provide pricing in cycles and USD for the 13-node baseline and the example of 34-node subnets. The linear scaling for a transaction is computed using the following formula, where *n* is the size of the subnet to compute the price for, **13_node_price** is the price for the transaction on the reference-size subnet with 13 nodes, and **DIV** is integer division:

***Price on n-node subnet = (13_node_price \* n) DIV 13***

Expand Down Expand Up @@ -42,21 +44,15 @@ Regarding transaction fees, the **transaction sender** is responsible for coveri
| _Chain-key signatures_ | | | | |
| Threshold ECDSA signing | For computing one threshold ECDSA signature (`sign_with_ecdsa`) | 10B / 13 | 10B | 10B / 13 * 34 |
| | | | | |
| _Coding Bitcoin_ | | | | |
| Bitcoin UTXO set for an address | For retrieving the UTXO set for a Bitcoin address (`bitcoin_get_utxos`) | 20M + 0.4 cycles per Wasm instruction | 20M + 0.4 cycles per Wasm instruction | 50M + 1 cycle per Wasm instruction |
| Bitcoin fee percentiles | For obtaining the fee percentiles of the most recent transactions (`bitcoin_get_current_fee_percentiles`) | 4M | 4M | 10M |
| Bitcoin balance for an address | For retrieving the balance of a given Bitcoin address (`bitcoin_get_balance`) | 4M | 4M | 10M |
| Bitcoin transaction submission | For submitting a Bitcoin transaction to the Bitcoin network, per transaction (`bitcoin_send_transaction`) | 2B | 2B | 5B |
| Bitcoin transaction payload | For submitting a Bitcoin transaction to the Bitcoin network, per byte of payload (`bitcoin_send_transaction`) | 8M | 8M | 20M |
| | | | | |
| _HTTPS outcalls_ | | | | |
| HTTPS outcall request | For sending an HTTPS outcall to a server outside the IC, per message (`http_request`) | 400M / 13 | 400M | 400M / 13 * 34 |
| HTTPS outcall payload | For sending an HTTPS outcall to a server outside the IC, per request and reserved response byte (`http_request`) | 100K / 13 | 100K | 100K / 13 * 34 |

### **Notes:**
Pricing for the Bitcoin API is available in the [Bitcoin API documentation](./integrations/bitcoin/bitcoin-how-it-works.md).

:::note
* System API calls are just like normal function calls from the WebAssembly stand point. The number of instructions each call takes depends on the work done.
* The Bitcoin canister for Bitcoin mainnet is launched initially on a 13-node subnet but the 34-node price as advertised above is charged to avoid frequent price changes. ***The Bitcoin API requires to send more cycles as specified for future-proofness.*** See the [Bitcoin documentation](https://internetcomputer.org/docs/current/developer-docs/integrations/bitcoin/bitcoin-how-it-works) for further details regarding the specifics of Bitcoin pricing.
* Prices for Bitcoin testnet are 40% of the prices for Bitcoin mainnet.
:::

The USD cost for transactions below is based on the above cycle costs. 1 XDR is equal to 1 Trillion cycles. As of November 23, 2022, the exchange rate for 1 XDR = $1.308860, which is used on this page. The exchange rate for USD/XDR may vary and it will impact the conversion rate. You can view XDR exchange rates [here](https://www.imf.org/external/np/fin/data/rms_sdrv.aspx).

Expand All @@ -77,20 +73,13 @@ To derive the estimated cost for a GB Storage per month, we assume a 30 day mont
| *Chain-key signatures* | | | |
| Threshold ECDSA signing | For computing one threshold ECDSA signature (`sign_with_ecdsa`) | $0.0130886 | $0.0342317 |
| | | | |
| *Coding Bitcoin* | | | |
| Bitcoin UTXO set for an address | For retrieving the UTXO set for a Bitcoin address (`bitcoin_get_utxos`) | $0.00002617720 + Wasm instruction cost | $0.00006544300 + Wasm instruction cost |
| Bitcoin fee percentiles | For obtaining the fee percentiles of the most recent transactions (`bitcoin_get_current_fee_percentiles`) | $0.00000523544 | $0.00001308860 |
| Bitcoin balance for an address | For retrieving the balance of a given Bitcoin address (`bitcoin_get_balance`) | $0.00000523544 | $0.00001308860 |
| Bitcoin transaction submission | For submitting a Bitcoin transaction to the Bitcoin network, per transaction (`bitcoin_send_transaction`) | $0.00261772000 | $0.00654430000 |
| Bitcoin transaction payload | For submitting a Bitcoin transaction to the Bitcoin network, per byte of payload (`bitcoin_send_transaction`) | $0.00001047088 | $0.00002617720 |
| | | | |
| *HTTPS outcalls* | | | |
| HTTPS outcall request | For sending an HTTPS outcall to a server outside the IC, per message (`http_request`) | $0.0005235440 | $0.0013692689 |
| HTTPS outcall payload | For sending an HTTPS outcall to a server outside the IC, per request and reserved response byte (`http_request`) | $0.0000001308860 | $0.0000003423166 |

Cost per Transaction in USD (XDR/USD exchange rate as of November 23, 2022):

Assuming a 30 day month — 
Assuming a 30-day month — 

| | | 13-node Application Subnets | 34-node Application Subnets |
|----------------------|------------------------------------|-----------------------------|-----------------------------|
Expand Down
Loading

0 comments on commit c9f8003

Please sign in to comment.