Skip to content
Cive

decodeDeployData

Decodes ABI encoded deploy data (bytecode & arguments).

The opposite of encodeDeployData.

Install

import { decodeDeployData } from "cive";

Usage

import {  } from "cive";
import {  } from "cive/chains";
import {  } from "./abi.js";
const {  } = ({
  : .,
  : ,
  :
    "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220116554d4ba29ee08da9e97dc54ff9a2a65d67a648140d616fc225a25ff08c86364736f6c63430008070033",
  : "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220116554d4ba29ee08da9e97dc54ff9a2a65d67a648140d616fc225a25ff08c86364736f6c634300080700330000000000000000000000000000000000000000000000000000000000010f2c",
});
// { args: [69420n], bytecode: '0x6080604...' }

Return Value

{
  args: unknown[] | undefined;
  bytecode: Hex;
}

Decoded deploy data.

Parameters

networkId

  • Type: Number

The network ID will be used for decoding the base32 address.

const { args } = decodeDeployData({
  networkId: mainnet.id, 
  bytecode:
    "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220116554d4ba29ee08da9e97dc54ff9a2a65d67a648140d616fc225a25ff08c86364736f6c63430008070033",
  data: "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220116554d4ba29ee08da9e97dc54ff9a2a65d67a648140d616fc225a25ff08c86364736f6c634300080700330000000000000000000000000000000000000000000000000000000000010f2c",
 
  abi: Abi,
});

abi

The contract's ABI.

const { args } = decodeDeployData({
  networkId: mainnet.id,
 
  bytecode:
    "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220116554d4ba29ee08da9e97dc54ff9a2a65d67a648140d616fc225a25ff08c86364736f6c63430008070033",
  data: "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220116554d4ba29ee08da9e97dc54ff9a2a65d67a648140d616fc225a25ff08c86364736f6c634300080700330000000000000000000000000000000000000000000000000000000000010f2c",
  abi: [
    {
      inputs: [
        {
          name: "abc",
          type: "uint256",
        },
      ],
      stateMutability: "nonpayable",
      type: "constructor",
    },
  ],
});

bytecode

Contract bytecode.

const { args } = decodeDeployData({
  networkId: mainnet.id,
  bytecode:
    "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220116554d4ba29ee08da9e97dc54ff9a2a65d67a648140d616fc225a25ff08c86364736f6c63430008070033",
  data: "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220116554d4ba29ee08da9e97dc54ff9a2a65d67a648140d616fc225a25ff08c86364736f6c634300080700330000000000000000000000000000000000000000000000000000000000010f2c",
 
  abi: Abi,
});

data

const { args } = decodeDeployData({
  networkId: mainnet.id,
  bytecode:
    "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220116554d4ba29ee08da9e97dc54ff9a2a65d67a648140d616fc225a25ff08c86364736f6c63430008070033",
  data: "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220116554d4ba29ee08da9e97dc54ff9a2a65d67a648140d616fc225a25ff08c86364736f6c634300080700330000000000000000000000000000000000000000000000000000000000010f2c",
 
  abi: Abi,
});