Type Alias alloy_contract::RawCallBuilder

source ·
pub type RawCallBuilder<T, P, N = Ethereum> = CallBuilder<T, P, (), N>;
Expand description

CallBuilder that does not have a call decoder.

Aliased Type§

struct RawCallBuilder<T, P, N = Ethereum> {
    pub provider: P,
    /* private fields */
}

Fields§

§provider: P

The provider.

Implementations§

source§

impl<T: Transport + Clone, P: Provider<T, N>, N: Network> RawCallBuilder<T, P, N>

source

pub fn with_sol_decoder<C: SolCall>(self) -> SolCallBuilder<T, P, C, N>

Sets the decoder to the provided SolCall.

Converts the raw call builder into a sol call builder.

Note that generally you would want to instantiate a sol call builder directly using the sol! macro, but this method is provided for flexibility, for example to convert a raw deploy call builder into a sol call builder.

§Examples

Decode a return value from a constructor:

sol! {
    // NOTE: This contract is not meant to be deployed on-chain, but rather
    // used in a static call with its creation code as the call data.
    #[sol(rpc, bytecode = "34601457602a60e052600161010052604060e0f35b5f80fdfe")]
    contract MyContract {
        // The type returned by the constructor.
        #[derive(Debug, PartialEq)]
        struct MyStruct {
            uint64 a;
            bool b;
        }

        constructor() {
            MyStruct memory s = MyStruct(42, true);
            bytes memory returnData = abi.encode(s);
            assembly {
                return(add(returnData, 0x20), mload(returnData))
            }
        }

        // A shim that represents the return value of the constructor.
        function constructorReturn() external view returns (MyStruct memory s);
    }
}

let provider = ...;
let call_builder = MyContract::deploy_builder(&provider)
    .with_sol_decoder::<MyContract::constructorReturnCall>();
let result = call_builder.call().await?;
assert_eq!(result.s, MyContract::MyStruct { a: 42, b: true });
source§

impl<T: Transport + Clone, P: Provider<T, N>, N: Network> RawCallBuilder<T, P, N>

source

pub fn new_raw(provider: P, input: Bytes) -> Self

Creates a new call builder with the provided provider and ABI encoded input.

Will not decode the output of the call, meaning that call will behave the same as call_raw.

source

pub fn new_raw_deploy(provider: P, input: Bytes) -> Self

Creates a new call builder with the provided provider and contract deploy code.

Will not decode the output of the call, meaning that call will behave the same as call_raw.