bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 13쪽 중 8쪽
IME
0x0000000000000000000000000000000000520009
Routing
Init code starting with
WASM_MAGIC_BYTES = 0x0061736d
(the standard Wasm 4-byte preamble) routes to this runtime. The dispatcher logic lives in
resolve_precompiled_runtime_from_input
in
fluentbase/crates/types/src/genesis.rs
. Direct calls to the runtime address are rejected.
Behavior
deploy_entry
compiles the input Wasm to rWasm via
RwasmModule::compile
, validates the result against
RWASM_MAX_CODE_SIZE = 12 MiB
, and returns the compiled module plus any constructor parameters. Compilation is metered:
WASM_COMPILATION_OVERHEAD_FUEL_PER_BYTE = 50 * FUEL_DENOM_RATE = 1000 fuel/byte = 50 gas/byte
A 100 KB Wasm payload pays roughly 5,000,000 gas just to compile. Estimate deploy cost accordingly.
After compilation, the executor installs the rWasm bytes at the deployed address (replacing the temporary ownable wrapper). The account's code field then starts with the rWasm magic prefix
0xEF52
, and subsequent calls execute the rWasm directly at that address —
main_entry
on this dispatcher returns
UnreachableCodeReached
and is never hit on a properly deployed contract. See the wrapper-rewrite path in
Runtime Routing and Ownable Accounts
.
Errors
MalformedBuiltinParams
—
RwasmModule::compile
rejected the input.
CreateContractSizeLimit
— compiled rWasm exceeds
RWASM_MAX_CODE_SIZE
.
UnreachableCodeReached
— only path through
main_entry
; should not be reached on a properly deployed contract.
Metadata syscalls and Wasm contracts
Metadata syscalls operate only on
Bytecode::OwnableAccount
. Because Wasm contracts are stored as
Bytecode::Rwasm
after the deploy rewrite, the syscalls behave as follows when called against a Wasm contract:
METADATA_SIZE
returns
size = 0
(graceful, no halt).
METADATA_ACCOUNT_OWNER
returns
Address::ZERO
(graceful, no halt).
METADATA_WRITE
and
METADATA_COPY
halt with
MalformedBuiltinParams
.
Source
fluentbase/contracts/wasm/
Address
Routing
Behavior
Errors
Metadata syscalls and Wasm contracts
Source
## /system-architecture/precompiles/universal-token-runtime
On this page
A shared ERC-20 implementation that every Universal Token deployment routes through. One contract, many tokens — each token is an ownable account pointing at this runtime, with its name, symbol, decimals, balances, and (optional) wrapped-token state stored under the account's own address.
Address
Constant
Address
PRECOMPILE_UNIVERSAL_TOKEN_RUNTIME
0x0000000000000000000000000000000000520008
Routing
Init code starting with
UNIVERSAL_TOKEN_MAGIC_BYTES = 0x45524320
(ASCII
"ERC "
) routes to this runtime at deploy time. Direct calls to the runtime address are rejected; user contracts reach it only via the ownable-account indirection.
Constructor payload
Deployment input is the magic prefix followed by the SolidityABI-encoded
InitialSettings
struct:
0x45524320 ++ abi.encode(token_name, token_symbol, decimals, initial_supply, minter, pauser, wrapped)
Field
ABI type
Notes
token_name
bytes32
Fixed 32-byte field, not a
string
(see below).
token_symbol
bytes32
Fixed 32-byte field.
decimals
uint8
Standard ERC-20 decimals.
initial_supply
uint256
Credited to deployer if non-zero.
minter
address
Stored even when zero; gates
mint
/
burn
.
pauser
address
Stored even when zero; gates
pause
/
unpause
.
wrapped
bool
Marks this token as a wrapped-asset deployment that gates
deposit
/
withdraw
.
Wrapped tokens cannot have a non-zero
minter
— deploys with
wrapped == true && minter != address(0)
are rejected with
ERR_UST_NOT_MINTABLE
.
bytes32
name and symbol — not
string
Name and symbol are 32-byte fixed values. The runtime reads the leading bytes of each
bytes32
, stops at the first
0x00
, and validates UTF-8 (malformed input is rejected with
MalformedBuiltinParams
). Encode human-readable text in the leading bytes; leave the tail zero-padded.
function
stringToBytes32
(
string
memory
s
)
internal
pure
returns
(
bytes32
out
)
{
require
(
bytes
(
s
)
.
length
<=
32
,
"string too long"
)
;
assembly
{
out
:=
mload
(
add
(
s
,
32
)
)
}
}
Deploy behavior
On a successful deploy the runtime:
stores
name
,
symbol
,
decimals
,
minter
,
pauser
, and the
wrapped
flag in account metadata,
if
initial_supply > 0
: credits the deployer's balance, sets
totalSupply
, and emits
Transfer(address(0), deployer, initial_supply)
.
A minimal Solidity-side deploy:
bytes4
constant
UNIVERSAL_TOKEN_MAGIC
=
0x45524320
;
// "ERC "
bytes
memory
initCode
=
bytes
.
concat
(
UNIVERSAL_TOKEN_MAGIC
,
abi
.
encode
(
name32
,
symbol32
,
decimals
,
initialSupply
,
minter
,
pauser
,
wrapped
)
)
;
address
token
;
assembly
{
token
:=
create
(
0
,
add
(
initCode
,
0x20
)
,
mload
(
initCode
)
)
}
CREATE2
works the same way with a salt argument.
Interface
Selectors are dispatched Solidity-style by 4-byte function ID. The runtime exposes the standard ERC-20 surface:
Selector
Returns
name()
string
symbol()
string
decimals()
uint8
totalSupply()
uint256
balanceOf(address)
uint256
transfer(address,uint256)
bool
transferFrom(address,address,uint256)
bool
approve(address,uint256)
bool
allowance(address,address)
uint256
Plus one Fluent-specific helper:
Selector
Returns
balance()
uint256
(caller's balance — equivalent to
balanceOf(msg.sender)
)
Privileged selectors active only when the corresponding role was set at deploy:
Selector
Role required
mint(address,uint256)
minter
burn(address,uint256)
minter
pause()
pauser
unpause()
pauser
Wrapped-asset selectors active only on tokens deployed with
wrapped == true
:
Selector
Behavior
deposit()
Mints the caller a wrapped balance equal to the
msg.value
sent.
withdraw(uint256 wad)
Burns the caller's wrapped balance and transfers the underlying value back.
Unknown selectors return
ERR_UST_UNKNOWN_METHOD
.
Events
event
Transfer
(
address
indexed
from
,
address
indexed
to
,
uint256
amount
)
;
event
Approval
(
address
indexed
owner
,
address
indexed
spender
,
uint256
amount
)
;
event
Paused
(
address
pauser
)
;
event
Unpaused
(
address
pauser
)
;
event
Deposit
(
address
indexed
dst
,
uint256
wad
)
;
event
Withdrawal
(
address
indexed
src
,
uint256
wad
)
;
Errors
Role and state checks return distinct error classes:
ERR_UST_NOT_MINTABLE
,
ERR_UST_MINTER_MISMATCH
— mint or burn against a token deployed without a minter, or by the wrong caller.
ERR_UST_NOT_PAUSABLE
,
ERR_UST_PAUSER_MISMATCH
— pause or unpause against a non-pausable token, or by the wrong caller.
ERR_UST_NOT_WRAPPED
—
deposit
/
withdraw
against a token deployed without
wrapped == true
.
ERR_PAUSABLE_ENFORCED_PAUSE
,
ERR_PAUSABLE_EXPECTED_PAUSE
— pause when already paused, unpause when not paused, or transfer / mint / burn while paused.
ERR_ERC20_INVALID_RECEIVER
,
ERR_ERC20_INVALID_SENDER
— mint to or burn from the zero address.
ERR_ERC20_INSUFFICIENT_BALANCE
,
ERR_ERC20_INSUFFICIENT_ALLOWANCE
— transfer or approve more than the caller has, or spend more than was approved.
Storage
Each Universal Token contract is stored as
Bytecode::OwnableAccount(owner = PRECOMPILE_UNIVERSAL_TOKEN_RUNTIME, metadata = original constructor input)
. The metadata payload is the SolidityABI-encoded
InitialSettings
struct itself; per-token configuration (name, symbol, decimals, minter, pauser, wrapped flag) is read from this metadata at runtime. Balances, allowances, and totalSupply live in the deployed account's regular storage slots.
Source
fluentbase/contracts/universal-token/
Address
Routing
Constructor payload
bytes32
name and symbol — not
string
Deploy behavior
Interface
Events
Errors
Storage
Source
## /system-architecture/precompiles/evm-runtime
On this page
The delegated EVM runtime dispatches calls and creates targeting Solidity-style contracts on Fluent. The address itself holds rWasm bytecode that wraps an EVM interpreter; every Solidity contract on Fluent is an ownable account whose
owner_address
field points here.
Address
Constant
Address
PRECOMPILE_EVM_RUNTIME
0x0000000000000000000000000000000000520001
Routing
Init code with no recognised magic prefix routes to this runtime — it is the default class. The dispatch rule lives in
Runtime Routing and Ownable Accounts
. Direct calls to the runtime address are rejected by the executor's
is_delegated_runtime_address
check.
Behavior
The runtime exposes two entry points used by REVM:
deploy_entry
runs at account creation. It runs the init code under the EVM interpreter, validates the deployed bytecode against EIP-3541 (no
0xEF
prefix) and EIP-170 (≤ 24 KB), charges
CODEDEPOSIT
per output byte, and writes the resulting deployed bytecode as
EthereumMetadata::Analyzed
into the account's ownable-account metadata.
main_entry
runs on every subsequent call. It reads the metadata, decodes it as
EthereumMetadata
, runs the EVM interpreter against the call input, syncs gas and fuel via
FUEL_DENOM_RATE = 20
at every interruption boundary, and returns the EVM-shaped result.
Nested calls and host operations (storage reads, balance queries, log emission) flow through the
interruption protocol
like any other system runtime. EVM bytecode is never the executing rWasm bytecode — it is always carried as metadata under the ownable-account wrapper.
Storage representation
Solidity contracts deploy as
Bytecode::OwnableAccount(owner = PRECOMPILE_EVM_RUNTIME, metadata = serialized EthereumMetadata)
. The wrapper layout is
0xEF44 || 0x00 || owner_address (20 bytes) || metadata (N bytes)
. The metadata payload begins with a 32-byte version header —
ETHEREUM_METADATA_VERSION_ANALYZED
signals an analyzed bytecode payload (bincode-encoded
(hash, len, padded_bytecode, jump_table)
); other values are treated as a legacy code hash followed by raw bytecode.
Errors
CreateContractStartingWithEF
— deployed bytecode begins with
0xEF
(EIP-3541 violation).
CreateContractSizeLimit
— deployed bytecode exceeds 24 KB (EIP-170 violation).
OutOfFuel
—
CODEDEPOSIT
charge fails or call-level fuel exhaustion.
Mapped EVM instruction results — standard EVM revert/halt classes propagated from the interpreter.
Source
fluentbase/contracts/evm/
Address
Routing
Behavior
Storage representation
Errors
Source
## /system-architecture/precompiles/runtime-upgrade
On this page
The contract-side of Fluent's runtime upgrade flow. The conceptual mechanism — governance owner, host enforcement, the privileged syscall — is documented in
Runtime Upgrade
.
Address
Constant
Address
PRECOMPILE_RUNTIME_UPGRADE
0x0000000000000000000000000000000000520010
Authority
Constant
Default address
DEFAULT_UPDATE_GENESIS_AUTH
0xa7bf6a9168fe8a111307b7c94b8883fe02b30934
The owner is initialized to the default at genesis. Live networks rotate it to a multisig immediately — treat the default as a starting point, not the current value. The contract reads its stored owner first and falls back to the default only when the slot is zero. Ownership transfer goes through
changeOwner(address)
(zero-address rejected);
renounceOwnership()
sets the owner to the system address (
0xfffffffffffffffffffffffffffffffffffffffe
), freezing future upgrades through the owner-based path.
Interface
Solidity-style 4-byte selector dispatch.
function
upgradeTo
(
address
target
,
uint256
genesisHash
,
string
genesisVersion
,
bytes
wasmBytecode
)
external
;
function
changeOwner
(
address
newOwner
)
external
;
function
owner
(
)
external
view
returns
(
address
)
;
function
renounceOwnership
(
)
external
;
The function selector for
upgradeTo
is published as a constant:
UPDATE_GENESIS_PREFIX = 0x288fb3b8 = keccak256("upgradeTo(address,uint256,string,bytes)")[:4]
upgradeTo
validates the input WASM starts with the WASM magic preamble, compiles it to rWasm via
compile_rwasm_maybe_system
, invokes
SYSCALL_ID_UPGRADE_RUNTIME
with the target address and serialized rWasm, then reads the installed code hash and emits
RuntimeUpgraded
. Failure at any step panics with a specific message that surfaces as an EVM revert — see Errors.
Events
event
RuntimeUpgraded
(
address
indexed
targetAddress
,
bytes32
indexed
genesisHash
,
string
genesisVersion
,
bytes32
codeHash
)
;
event
OwnerChanged
(
address
newOwner
)
;
RuntimeUpgraded
is emitted on every successful
upgradeTo
after the host installs the new bytecode at
targetAddress
;
codeHash
is the hash of the installed bytecode.
OwnerChanged
is emitted by
changeOwner
and
renounceOwnership
.
Errors
All failure paths use Rust
panic!
and surface as EVM revert. Messages:
runtime-upgrade: incorrect caller
runtime-upgrade: malformed wasm bytecode
runtime-upgrade: failed to compile bytecode
runtime-upgrade: failed to upgrade
runtime-upgrade: can't obtain code hash
runtime-upgrade: can't set owner to zero address
Routing note
PRECOMPILE_RUNTIME_UPGRADE
is not in
EXECUTE_USING_SYSTEM_RUNTIME_ADDRESSES
. The contract is pre-deployed at genesis and executes as a normal rWasm contract — no system-runtime envelope, no per-runtime storage prefetch. Standard
CALL
semantics apply.
Source
fluentbase/contracts/runtime-upgrade/
. CLI driver:
fluentbase/bins/runtime-upgrade/main.rs
.
Address
Authority
Interface
Events
Errors
Routing note
Source
## /system-architecture/precompiles/fee-manager
On this page
The system contract that holds accumulated protocol fees. The owner can withdraw the contract's full balance to a recipient address. There is no other operation; fees are paid into this address by the protocol and accumulate until withdrawn.
Address
Constant
Address
PRECOMPILE_FEE_MANAGER
0x0000000000000000000000000000000000520fee
Authority
Constant
Default address
DEFAULT_FEE_MANAGER_AUTH
0xa7bf6a9168fe8a111307b7c94b8883fe02b30934
The owner defaults to the genesis-init value. Live networks rotate it. The contract reads its stored owner first and falls back to the default only when the slot is zero.
changeOwner(address)
transfers ownership (zero-address rejected);
renounceOwnership()
sets the owner to the system address (
0xfffffffffffffffffffffffffffffffffffffffe
).
Interface
function
withdraw
(
address
recipient
)
external
;
function
changeOwner
(
address
newOwner
)
external
;
function
owner
(
)
external
view
returns
(
address
)
;
function
renounceOwnership
(
)
external
;
withdraw
is owner-only and transfers the contract's full balance to
recipient
. Reverts if the contract balance is zero (
fee-manager: nothing to withdraw
).
Events
event
FeeWithdrawn
(
address
recipient
,
uint256
amount
)
;
event
OwnerChanged
(
address
newOwner
)
;
Errors
All failure paths use Rust
panic!
and surface as EVM revert. Messages:
fee-manager: incorrect caller
fee-manager: nothing to withdraw
fee-manager: can't send funds to recipient
fee-manager: can't obtain self balance
Routing note
PRECOMPILE_FEE_MANAGER
is not in
EXECUTE_USING_SYSTEM_RUNTIME_ADDRESSES
. The contract is pre-deployed at genesis and executes as a normal rWasm contract — no system-runtime envelope, no per-runtime storage prefetch. Standard
CALL
semantics apply.
Source
fluentbase/contracts/fee-manager/
Address
Authority
Interface
Events
Errors
Routing note
Source
## /system-architecture/precompiles/create2-factory
On this page
A deterministic deployment proxy installed at the same address Fluent shares with most EVM-compatible chains. A deployer broadcasts a single transaction with init bytecode and a 32-byte salt; the factory deploys the contract via
CREATE2
and returns its address. Used for cross-chain address parity — identical bytecode plus identical salt yields the same address on any chain that has this factory at the same location.
Address
Constant
Address
PRECOMPILE_CREATE2_FACTORY
0x4e59b44847b379578588920cA78FbF26c0B4956C
PRECOMPILE_CREATE2_FACTORY_DEPLOYER
0x3fab184622dc19b6109349b94811493bf2a45362
Provenance
This is
Arachnid's deterministic deployment proxy
. Fluent embeds it at genesis using the same bytecode and the same address as Ethereum mainnet, so addresses derived against this factory match on all chains that include it. The factory has no Rust contract crate — the artifacts are checked-in Yul source plus the compiled binary at
contracts/create2-factory/
.
Calling convention
The factory is a Yul-level contract with no Solidity ABI. Calldata format:
| 32 bytes salt | N bytes init code |
The factory hashes the calldata, runs
CREATE2(value=msg.value, salt, init_code)
, and returns the deployed address. Reverts if
CREATE2
fails.
Storage representation
The factory is an EVM contract — its on-chain state is
Bytecode::OwnableAccount(owner = PRECOMPILE_EVM_RUNTIME, metadata = EthereumMetadata payload)
. The payload wraps the 73-byte Yul-compiled bytecode. Calls to the factory dispatch through the EVM runtime like any other Solidity contract — see
EVM Runtime
.
Source
fluentbase/contracts/create2-factory/
—
deterministic-deployment-proxy.bin
(binary),
deterministic-deployment-proxy.yul
(source).
Address
Provenance
Calling convention
Storage representation
Source
## /system-architecture/precompiles/eip2935
On this page
A ring buffer of historical block hashes accessible from contracts. Implements
EIP-2935
— the Prague-era replacement for the
BLOCKHASH
opcode that lets contracts read further back than 256 blocks.
Address
Constant
Address
PRECOMPILE_EIP2935
0x0000F90827F1C53a10cb7A02335B175320002935
Behavior
Two paths gated by caller:
Read path
(any caller). Calldata is a 32-byte big-endian block number. Returns the 32-byte block hash from the ring slot
block_number % 8191
. Block numbers older than the window or greater than
current_block - 1
revert.
Write path
(only callable by the system address
0xfffffffffffffffffffffffffffffffffffffffe
). The protocol calls into this path at every block transition to store the new hash at slot
(current_block - 1) % 8191
.
The window is fixed at
EIP2935_HISTORY_SERVE_WINDOW = 8191
slots.
Gas
Gas charges are precise per-branch, matching the EVM control flow specified by the EIP. Each value is in EVM gas units; fuel is charged as
gas * FUEL_DENOM_RATE
.
Branch
EVM gas
Bad input length
47
Future block (
block_number > current - 1
)
79
Block too old (
block_number < current - 8191
)
106
Successful read
125
Successful write (system caller)
43
A successful read costs 125 gas = 2,500 fuel.
Source
fluentbase/contracts/eip2935/
Address
Behavior
Gas
Source
## /system-architecture/precompiles/secp256r1
On this page
A signature verification precompile for the NIST P-256 curve (secp256r1). Tracked as
EIP-7951
on the EIP track and
RIP-7212
on the rollup track. Same curve used by WebAuthn, FIDO2, and most non-Ethereum chains for ECDSA — distinct from secp256k1, which underlies Ethereum's
ecrecover
.
Address
Constant
Address
PRECOMPILE_EIP7951
0x0000000000000000000000000000000000000100
Calling convention
Input: 160 bytes total, big-endian.
| msgHash (32) | r (32) | s (32) | pubKeyX (32) | pubKeyY (32) |
Output:
Valid signature: 1 byte
0x01
.
Invalid signature, malformed coordinates, or input length other than 160 bytes: empty bytes.
Invalid signatures and malformed coordinates are
not
errors — the precompile returns success with empty output. The contract is a thin wrapper around
revm_precompile::secp256r1::p256_verify
.
Gas
Flat cost per call:
P256VERIFY_BASE_GAS_FEE = 3,450 gas
. Charged unconditionally before verification runs.
Errors
OutOfFuel
—
revm_precompile
returned
PrecompileError::OutOfGas
.
PrecompileError
— any other underlying precompile error.
Source
fluentbase/contracts/eip7951/
. Underlying implementation:
revm_precompile::secp256r1
.
Address
Calling convention
Gas
Errors
Source
## /system-architecture/precompiles/standard-evm-precompiles
프로젝트로 돌아가기