Appearance
PopcodeContract
PopcodeContract
extends ethers.Contract and provides an interface for interacting with smart contract. It includes methods for preparing transaction data, retrieving contract details, and managing roles and proofs within the contract.
To deploy a new contract, use the Popcode methods: prepareDeployTxFromTracker
or prepareDeployTx
, depending on whether database dependencies are involved or not respectively.
Creating Instances
new PopcodeContract( target: string
, contractRunner: Signer | Provider )
Creates a new instance of PopcodeContract
connected to the specified contract address, using the provided signer or provider for interactions.
Properties
popcodeContract.target ⇒
string
The target to connect to. This can be an address, ENS name or any Addressable, such as another contract.popcodeContract.contractRunner ⇒
Signer | Provider
The Signer or Provider used for interacting with the contract.
To query or retrieve blockchain details, use the
Provider
, while for executing transactions, use theSigner
.
Methods
popcodeContract.prepareTxData ( methodName: string
, args: any[]
, signerAddress: string
) ⇒ Promise< TxData
>
Prepares the transaction data for invoking a method on the contract by generating the required data.
popcodeContract.getRoleForByte ( roleByte: string
) ⇒ string
Translates a role byte into a readable role name (e.g., ADMIN_ROLE
, MINTER_ROLE
).
popcodeContract.getProofs () ⇒ Promise<Proofs
>
Fetches proofs from the contract, mapping each cid
to its associated address.
popcodeContract.getTokens () ⇒ Promise<Tokens
>
Retrieves all token balances from the contract, mapping token IDs to their respective addresses and quantities.
popcodeContract.getParents () ⇒ Promise<string[]
>
Gets a list of parent addresses associated with the contract.
popcodeContract.getChildren () ⇒ Promise< string[]
>
Gets a list of child addresses associated with the contract.
popcodeContract.getRoles () ⇒ Promise< Roles
>
Fetches the roles assigned to various addresses within the contract, translating role bytes into human-readable names using getRoleForByte
.
popcodeContract.getDetails ( popcodeAddress: string
) ⇒ Promise< EvmPopcode
>
Fetches details for a given Popcode address, including roles, tokens, proofs, children, and parents.
popcodeContract.getTrail ( popcodeAddress: string
) ⇒ Promise< Trail
[] >
Generates a provenance trail for a given Popcode address, including event logs and timestamps.
Note: The
PopcodeContract
class also allows interaction with the deployed Popcode Contract's functions. For more details, refer to the Popcode Contract Artifact.