Skip to content

Commit

Permalink
Simplify ABI encoding (#1821)
Browse files Browse the repository at this point in the history
  • Loading branch information
khadni authored Mar 18, 2024
1 parent 088594d commit 25c4e70
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/content/chainlink-functions/tutorials/abi-decoding.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,8 @@ const complexData = {
// Define the Solidity types for encoding
const types = ["tuple(uint256 id, tuple(string description, bool awesome) metadata)"]

// Data to encode
const data = [
[
complexData.id,
{
description: complexData.metadata.description,
awesome: complexData.metadata.awesome,
},
],
]

// Encoding the data
const encodedData = abiCoder.encode(types, data)
const encodedData = abiCoder.encode(types, [complexData])
```

After encoding the data, it's necessary to format it as a `Uint8Array` array for smart contract interactions and blockchain transactions. In Solidity, the data type for byte arrays data is `bytes`. However, when working in a JavaScript environment, such as when using the `ethers.js` library, the equivalent data structure is a `Uint8Array`.
Expand Down

0 comments on commit 25c4e70

Please sign in to comment.