# ABI解码 **Published by:** [web3zoom](https://paragraph.com/@web3zoom/) **Published on:** 2025-09-30 **URL:** https://paragraph.com/@web3zoom/abi ## Content abi的编码和解码过程: 1、abi.encode 2、abi.decode// SPDX-License-Identifier: MIT pragma solidity ^0.8.30; contract abiDecode { struct MyStruct{ string name; uint[2] nums; } function encode(uint x, address addr, uint[] calldata arr, MyStruct calldata myStruct) external pure returns(bytes memory){ return abi.encode(x,addr,arr,myStruct); } function decode(bytes calldata data) external pure returns( uint x, address addr, uint[] memory arr, MyStruct memory myStruct ){ (x,addr,arr,myStruct) = abi.decode(data, (uint, address, uint[], MyStruct)); } } ## Publication Information - [web3zoom](https://paragraph.com/@web3zoom/): Publication homepage - [All Posts](https://paragraph.com/@web3zoom/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@web3zoom): Subscribe to updates - [Twitter](https://twitter.com/primer2011): Follow on Twitter