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>
impl<T: Transport + Clone, P: Provider<T, N>, N: Network> RawCallBuilder<T, P, N>
sourcepub fn with_sol_decoder<C: SolCall>(self) -> SolCallBuilder<T, P, C, N>
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 });