Skip to content

Utility


Calls


as_derivative

Send a call through an indexed pseudonym of the sender.

Filter from origin are passed along. The call will be dispatched with an origin which use the same filter as the origin of this call.

NOTE: If you need to ensure that any account-based filtering is not honored (i.e. because you expect proxy to have been used prior in the call stack and you do not want the call restrictions to apply to any sub-accounts), then use as_multi_threshold_1 in the Multisig pallet instead.

NOTE: Prior to version *12, this was called as_limited_sub.

The dispatch origin for this call must be Signed.

Attributes

Name Type
index u16
call Box<<T as Config>::RuntimeCall>

Python

call = substrate.compose_call(
    'Utility', 'as_derivative', {'call': 'Call', 'index': 'u16'}
)

batch

Send a batch of dispatch calls.

May be called from any origin except None.

  • calls: The calls to be dispatched from the same origin. The number of call must not exceed the constant: batched_calls_limit (available in constant metadata).

If origin is root then the calls are dispatched without checking origin filter. (This includes bypassing frame_system::Config::BaseCallFilter).

## Complexity - O(C) where C is the number of calls to be batched.

This will return Ok in all circumstances. To determine the success of the batch, an event is deposited. If a call failed and the batch was interrupted, then the BatchInterrupted event is deposited, along with the number of successful calls made and the error of the failed call. If all were successful, then the BatchCompleted event is deposited.

Attributes

Name Type
calls Vec<<T as Config>::RuntimeCall>

Python

call = substrate.compose_call(
    'Utility', 'batch', {'calls': ['Call']}
)

batch_all

Send a batch of dispatch calls and atomically execute them. The whole transaction will rollback and fail if any of the calls failed.

May be called from any origin except None.

  • calls: The calls to be dispatched from the same origin. The number of call must not exceed the constant: batched_calls_limit (available in constant metadata).

If origin is root then the calls are dispatched without checking origin filter. (This includes bypassing frame_system::Config::BaseCallFilter).

## Complexity - O(C) where C is the number of calls to be batched.

Attributes

Name Type
calls Vec<<T as Config>::RuntimeCall>

Python

call = substrate.compose_call(
    'Utility', 'batch_all', {'calls': ['Call']}
)

dispatch_as

Dispatches a function call with a provided origin.

The dispatch origin for this call must be Root.

## Complexity - O(1).

Attributes

Name Type
as_origin Box<T::PalletsOrigin>
call Box<<T as Config>::RuntimeCall>

Python

call = substrate.compose_call(
    'Utility', 'dispatch_as', {
    'as_origin': {
        'Void': (),
        'system': {
            'None': None,
            'Root': None,
            'Signed': 'AccountId',
        },
    },
    'call': 'Call',
}
)

force_batch

Send a batch of dispatch calls. Unlike batch, it allows errors and won&#x27;t interrupt.

May be called from any origin except None.

  • calls: The calls to be dispatched from the same origin. The number of call must not exceed the constant: batched_calls_limit (available in constant metadata).

If origin is root then the calls are dispatch without checking origin filter. (This includes bypassing frame_system::Config::BaseCallFilter).

## Complexity - O(C) where C is the number of calls to be batched.

Attributes

Name Type
calls Vec<<T as Config>::RuntimeCall>

Python

call = substrate.compose_call(
    'Utility', 'force_batch', {'calls': ['Call']}
)

with_weight

Dispatch a function call with a specified weight.

This function does not check the weight of the call, and instead allows the Root origin to specify the weight of the call.

The dispatch origin for this call must be Root.

Attributes

Name Type
call Box<<T as Config>::RuntimeCall>
weight Weight

Python

call = substrate.compose_call(
    'Utility', 'with_weight', {
    'call': 'Call',
    'weight': {
        'proof_size': 'u64',
        'ref_time': 'u64',
    },
}
)

Events


BatchCompleted

Batch of dispatches completed fully with no error.

Attributes

No attributes


BatchCompletedWithErrors

Batch of dispatches completed but has errors.

Attributes

No attributes


BatchInterrupted

Batch of dispatches did not complete fully. Index of first failing dispatch given, as well as the error.

Attributes

Name Type Composition
index u32 u32
error DispatchError {'Other': None, 'CannotLookup': None, 'BadOrigin': None, 'Module': {'index': 'u8', 'error': '[u8; 4]'}, 'ConsumerRemaining': None, 'NoProviders': None, 'TooManyConsumers': None, 'Token': ('NoFunds', 'WouldDie', 'BelowMinimum', 'CannotCreate', 'UnknownAsset', 'Frozen', 'Unsupported'), 'Arithmetic': ('Underflow', 'Overflow', 'DivisionByZero'), 'Transactional': ('LimitReached', 'NoLayer'), 'Exhausted': None, 'Corruption': None, 'Unavailable': None}

DispatchedAs

A call was dispatched.

Attributes

Name Type Composition
result DispatchResult {'Ok': (), 'Err': {'Other': None, 'CannotLookup': None, 'BadOrigin': None, 'Module': {'index': 'u8', 'error': '[u8; 4]'}, 'ConsumerRemaining': None, 'NoProviders': None, 'TooManyConsumers': None, 'Token': ('NoFunds', 'WouldDie', 'BelowMinimum', 'CannotCreate', 'UnknownAsset', 'Frozen', 'Unsupported'), 'Arithmetic': ('Underflow', 'Overflow', 'DivisionByZero'), 'Transactional': ('LimitReached', 'NoLayer'), 'Exhausted': None, 'Corruption': None, 'Unavailable': None}}

ItemCompleted

A single item within a Batch of dispatches has completed with no error.

Attributes

No attributes


ItemFailed

A single item within a Batch of dispatches has completed with error.

Attributes

Name Type Composition
error DispatchError {'Other': None, 'CannotLookup': None, 'BadOrigin': None, 'Module': {'index': 'u8', 'error': '[u8; 4]'}, 'ConsumerRemaining': None, 'NoProviders': None, 'TooManyConsumers': None, 'Token': ('NoFunds', 'WouldDie', 'BelowMinimum', 'CannotCreate', 'UnknownAsset', 'Frozen', 'Unsupported'), 'Arithmetic': ('Underflow', 'Overflow', 'DivisionByZero'), 'Transactional': ('LimitReached', 'NoLayer'), 'Exhausted': None, 'Corruption': None, 'Unavailable': None}

Constants


batched_calls_limit

The limit on the number of batched calls.

Value

10922

Python

constant = substrate.get_constant('Utility', 'batched_calls_limit')

Errors


TooManyCalls

Too many calls batched.