Struct fuels_core::abi_decoder::ABIDecoder
source · pub struct ABIDecoder;
Implementations§
source§impl ABIDecoder
impl ABIDecoder
sourcepub fn decode(
param_types: &[ParamType],
bytes: &[u8]
) -> Result<Vec<Token>, CodecError>
pub fn decode(
param_types: &[ParamType],
bytes: &[u8]
) -> Result<Vec<Token>, CodecError>
Decodes types described by param_types
into their respective Token
s
using the data in bytes
and receipts
.
Arguments
param_types
: The ParamType’s of the types we expect are encoded insidebytes
andreceipts
.bytes
: The bytes to be used in the decoding process.
Examples
use fuels_core::abi_decoder::ABIDecoder;
use fuels_core::Token;
use fuels_types::param_types::ParamType;
let tokens = ABIDecoder::decode(&[ParamType::U8, ParamType::U8], &[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,2]).unwrap();
assert_eq!(tokens, vec![Token::U8(1), Token::U8(2)])
sourcepub fn decode_single(
param_type: &ParamType,
bytes: &[u8]
) -> Result<Token, CodecError>
pub fn decode_single(
param_type: &ParamType,
bytes: &[u8]
) -> Result<Token, CodecError>
The same as decode
just for a single type. Used in most cases since
contract functions can only return one type.