Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/basics/precompiles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: Precompiles
slug: /basics/precompiles
hide_title: true
---

![Precompiles Title Picture](/img/title/precompiles.svg)

# Precompiles

[Precompiles](https://docs.polkadot.com/develop/smart-contracts/precompiles/) are pre-defined functions implemented directly into the blockchain's runtime, unlike smart contracts that execute within the virtual machine. This makes heavy operations cheaper and also turns precompiles into adapters that let smart contracts call into chain features. Precompiles exist at predetermined addresses and offer optimized performance with lower gas costs than equivalent contract
implementations.

## Using Precompiles in ink! Contracts

In ink!, precompiles are called exactly like any other contract using the same [cross-contract calling mechanisms](./cross-contract-calling.md). You simply target the precompile's predetermined address instead of a deployed contract address.

## Discovering Chains Precompiles

To find available precompiles on a Polkadot SDK chain, check the runtime configuration in the `pallet-revive` section for the `Precompiles` type definition.

```rust
impl pallet_revive::Config for Runtime {
...
type Precompiles = MyChainPrecompiles;
...
}
```
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
"basics/trait-definitions",
"basics/gas",
"basics/cross-contract-calling",
"basics/precompiles",
"basics/upgradeability",
"basics/env-functions",
"basics/environment",
Expand Down
Loading