Skip to main content

Gas and ink costs

This reference provides the latest gas and ink costs for specific WASM opcodes and host I/Os when using Stylus. For a conceptual introduction to Stylus gas and ink, see Gas and ink (Stylus).

PUBLIC PREVIEW DOCUMENT

This document is currently in public preview and may change significantly as feedback is captured from readers like you. Click the Request an update button at the top of this document or join the Arbitrum Discord to share your feedback.

Opcode costs

The Stylus VM charges for WASM opcodes according to the following table, which was determined via a conservative statistical analysis and is expected to change as Stylus matures. Prices may fluctuate across upgrades as our analysis evolves and optimizations are made.

HexOpcodeInkGasNotes
0x00Unreachable10.0001
0x01Nop10.0001
0x02Block10.0001
0x03Loop10.0001
0x04If7650.0765
0x05Else10.0001
0x0bEnd10.0001
0x0cBr7650.0765
0x0dBrIf7650.0765
0x0eBrTable2400 + 325x0.24 + 0.0325xCost varies with table size
0x0fReturn10.0001
0x10Call38000.38
0x11CallIndirect13610 + 650x1.361 + 0.065xCost varies with no. of args
0x1aDrop90.0009
0x1bSelect12500.125
0x20LocalGet750.0075
0x21LocalSet2100.0210
0x22LocalTee750.0075
0x23GlobalGet2250.0225
0x24GlobalSet5750.0575
0x28I32Load6700.067
0x29I64Load6800.068
0x2cI32Load8S6700.067
0x2dI32Load8U6700.067
0x2eI32Load16S6700.067
0x2fI32Load16U6700.067
0x30I64Load8S6800.068
0x31I64Load8U6800.068
0x32I64Load16S6800.068
0x33I64Load16U6800.068
0x34I64Load32S6800.068
0x35I64Load32U6800.068
0x36I32Store8250.0825
0x37I64Store9500.095
0x3aI32Store88250.0825
0x3bI32Store168250.0825
0x3cI64Store89500.095
0x3dI64Store169500.095
0x3eI64Store329500.095
0x3fMemorySize30000.3
0x40MemoryGrow80500.805
0x41I32Const10.0001
0x42I64Const10.0001
0x45I32Eqz1700.017
0x46I32Eq1700.017
0x47I32Ne1700.017
0x48I32LtS1700.017
0x49I32LtU1700.017
0x4aI32GtS1700.017
0x4bI32GtU1700.017
0x4cI32LeS1700.017
0x4dI32LeU1700.017
0x4eI32GeS1700.017
0x4fI32GeU1700.017
0x50I64Eqz2250.0225
0x51I64Eq2250.0225
0x52I64Ne2250.0225
0x53I64LtS2250.0225
0x54I64LtU2250.0225
0x55I64GtS2250.0225
0x56I64GtU2250.0225
0x57I64LeS2250.0225
0x58I64LeU2250.0225
0x59I64GeS2250.0225
0x5aI64GeU2250.0225
0x67I32Clz2100.021
0x68I32Ctz2100.021
0x69I32Popcnt26500.265
0x6aI32Add700.007
0x6bI32Sub700.007
0x6cI32Mul1600.016
0x6dI32DivS11200.112
0x6eI32DivU11200.112
0x6fI32RemS11200.112
0x70I32RemU11200.112
0x71I32And700.007
0x72I32Or700.007
0x73I32Xor700.007
0x74I32Shl700.007
0x75I32ShrS700.007
0x76I32ShrU700.007
0x77I32Rotl700.007
0x78I32Rotr700.007
0x79I64Clz2100.021
0x7aI64Ctz2100.012
0x7bI64Popcnt60000.6
0x7cI64Add1000.01
0x7dI64Sub1000.01
0x7eI64Mul1600.016
0x7fI64DivS12700.127
0x80I64DivU12700.127
0x81I64RemS12700.127
0x82I64RemU12700.127
0x83I64And1000.01
0x84I64Or1000.01
0x85I64Xor1000.01
0x86I64Shl1000.01
0x87I64ShrS1000.01
0x88I64ShrU1000.01
0x89I64Rotl1000.01
0x8aI64Rotr1000.01
0xa7I32WrapI641000.01
0xacI64ExtendI32S1000.01
0xadI64ExtendI32U1000.01
0xc0I32Extend8S1000.01
0xc1I32Extend16S1000.01
0xc2I64Extend8S1000.01
0xc3I64Extend16S1000.01
0xc4I64Extend32S1000.01
0xfc0aMemoryCopy950 + 100x0.095 + 0.01xCost varies with no. of bytes
0xfc0bMemoryFill950 + 100x0.095 + 0.01xCost varies with no. of bytes

Host I/O costs

Certain operations require suspending WASM execution so that the Stylus VM can perform tasks natively in the host. This costs about 0.84 gas to do. Though we’ll publish a full specification later, the following table details the costs of simple operations that run in the host.

Note that the values in this table were determined via a conservative statistical analysis and are expected to change as Stylus matures. Prices may fluctuate across upgrades as our analysis evolves and optimizations are made.

Host I/OInkGasNotes
read_args8400 + 5040b0.84 + 0.504bb = bytes after first 32
write_result8400 + 16381b0.84 + 1.6381bb = bytes after first 32
keccak121800 + 21000w12.18 + 2.1ww = EVM words
block_basefee134401.344
block_coinbase134401.344
block_gas_limit84000.84
block_number84000.84
block_timestmap84000.84
chain_id84000.84
contract_address134401.344
evm_gas_left84000.84
evm_ink_left84000.84
msg_reentrant84000.84
msg_sender134401.344
msg_value134401.344
return_data_size84000.84
tx_ink_price84000.84
tx_gas_price134401.344
tx_origin134401.344
console_log_text00debug-only
console_log00debug-only
console_tee00debug-only
null_host00debug-only

See also