Skip to content

Contract Syscalls

Back to Syscalls

Contract syscalls handle cross-contract invocation and account creation.

Syscall NameGas CostDescriptionDevpack Wrapper
System.Contract.Call10Cross-contract callSyscalls.contractCall(hash, method, params)
System.Contract.GetCallFlags10Get current call flagsSyscalls.getCallFlags()
System.Contract.CreateStandardAccount10Create account from public keySyscalls.createStandardAccount(pubkey)
System.Contract.CreateMultisigAccount10Create multisig accountSyscalls.createMultisigAccount(m, pubkeys)
solidity
import "devpack/contracts/Syscalls.sol";

contract Bridge {
    address constant GAS_CONTRACT = 0xd2a4cff31913016155e38e474a2c06d08be276cf;

    function checkBalance(address account) external returns (bytes memory) {
        // Cross-contract call to the GAS native contract (10 GAS units)
        bytes memory params = abi.encode(account);
        return Syscalls.contractCall(GAS_CONTRACT, "balanceOf", params);
    }

    function createMultisig(uint256 threshold, bytes[] memory pubkeys)
        external
        returns (address)
    {
        // Create a multisig account requiring `threshold` of `pubkeys`
        return Syscalls.createMultisigAccount(threshold, pubkeys);
    }
}

CallFlags

The System.Contract.GetCallFlags syscall returns the permission flags for the current execution context. These flags control what operations the called contract is allowed to perform.

FlagValueDescription
None0x00No permissions
ReadStates0x01Can read storage and call other contracts
WriteStates0x02Can write to storage
AllowCall0x04Can make cross-contract calls
AllowNotify0x08Can emit notifications
All0x0FFull permissions (default for direct calls)

TIP

When calling another contract, you can restrict its permissions by passing specific call flags. This is a defense-in-depth mechanism — a called contract with ReadStates only cannot modify your storage even if it contains malicious code.

MIT Licensed