-
Notifications
You must be signed in to change notification settings - Fork 490
/
syscalls.cairo
92 lines (79 loc) · 3.89 KB
/
syscalls.cairo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use starknet::{
SyscallResult, storage_access::StorageAddress, class_hash::ClassHash,
contract_address::ContractAddress
};
// Calls a given contract.
// `address` - The address of the called contract.
// `entry_point_selector` - A selector for a function within that contract.
// `calldata` - Call arguments.
extern fn call_contract_syscall(
address: ContractAddress, entry_point_selector: felt252, calldata: Span<felt252>
) -> SyscallResult<Span<felt252>> implicits(GasBuiltin, System) nopanic;
// Deploys a new instance of a previously declared class.
// `class_hash` - The class hash of the contract to be deployed.
// `contract_address_salt` - The salt, an arbitrary value provided by the sender, used in the
// computation of the contract's address.
// `calldata` - Call arguments for the constructor.
// `deploy_from_zero` - Deploy the contract from the zero address.
extern fn deploy_syscall(
class_hash: ClassHash,
contract_address_salt: felt252,
calldata: Span<felt252>,
deploy_from_zero: bool,
) -> SyscallResult<(ContractAddress, Span<felt252>)> implicits(GasBuiltin, System) nopanic;
// Emits an event.
// `keys` - The keys of the event.
// `data` - The data of the event.
extern fn emit_event_syscall(
keys: Span<felt252>, data: Span<felt252>
) -> SyscallResult<()> implicits(GasBuiltin, System) nopanic;
// Gets the block hash of the block with the given number.
extern fn get_block_hash_syscall(
block_number: u64
) -> SyscallResult<felt252> implicits(GasBuiltin, System) nopanic;
// Gets information about the current execution.
extern fn get_execution_info_syscall() -> SyscallResult<Box<starknet::info::ExecutionInfo>> implicits(
GasBuiltin, System
) nopanic;
// Calls the requested function in any previously declared class.
// `class_hash` - The hash of the class you want to use.
// `function_selector` - A selector for a function within that class.
// `calldata` - Call arguments.
extern fn library_call_syscall(
class_hash: ClassHash, function_selector: felt252, calldata: Span<felt252>
) -> SyscallResult<Span<felt252>> implicits(GasBuiltin, System) nopanic;
// TODO(Ilya): Decide if we limit the type of `to_address`.
// Sends a message to L1.
// `to_address` - The recipient's L1 address.
// `payload` - The content of the message.
extern fn send_message_to_l1_syscall(
to_address: felt252, payload: Span<felt252>
) -> SyscallResult<()> implicits(GasBuiltin, System) nopanic;
// Gets the value of a key in the storage of the calling contract.
// `address_domain` - The domain of the address. Only address_domain 0 is currently supported,
// in the future it will enable access to address spaces with different data availability
// guarantees.
// `address` - The address of the storage key to read.
extern fn storage_read_syscall(
address_domain: u32, address: StorageAddress,
) -> SyscallResult<felt252> implicits(GasBuiltin, System) nopanic;
// Sets the value of a key in the storage of the calling contract.
// `address_domain` - The domain of the address. Only address_domain 0 is currently supported,
// in the future it will enable access to address spaces with different data availability
// guarantees.
// `address` - The address of the storage key to write.
// `value` - The value to write to the key.
extern fn storage_write_syscall(
address_domain: u32, address: StorageAddress, value: felt252
) -> SyscallResult<()> implicits(GasBuiltin, System) nopanic;
// Replaces the class hash of the current contract.
// `class_hash` - The class hash that should replace the current one.
extern fn replace_class_syscall(
class_hash: ClassHash
) -> SyscallResult<()> implicits(GasBuiltin, System) nopanic;
// Computes the keccak of the input.
// The system call does not add any padding and the input needs to be a multiple of 1088 bits
// (== 17 u64 word).
extern fn keccak_syscall(
input: Span<u64>
) -> SyscallResult<u256> implicits(GasBuiltin, System) nopanic;