New: Introducing PHP and Composer Support.Read the Announcement
Socket
Book a DemoInstallSign in
Socket

@iexec/poco

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iexec/poco

[![codecov](https://codecov.io/github/iExecBlockchainComputing/PoCo/graph/badge.svg)](https://codecov.io/github/iExecBlockchainComputing/PoCo)

Source
npmnpm
Version
5.6.0-rc0
Version published
Weekly downloads
88
-68.9%
Maintainers
2
Weekly downloads
 
Created
Source

iExec PoCo Smart Contracts

codecov

Introduction

This repository contains the smart contract implementation of iExec's PoCo protocol.

PoCo UMLs

Documentation

Audits

All contract audit files can be found in audit/ folder.

How to?

Configure a deployment

Starting from version 5, the PoCo uses a modular design based on ERC1538. The migration scripts and tests will use different modules and deployment process depending on the required configuration. In particular, the configuration can use a create2 factory for the deployment, and enable native token or ERC20 token based escrow depending on the targeted blockchain. This means that the codebase is the same on public blockchains (ERC20 based RLC) and dedicated sidechains (Native token based RLC).

The configuration file is located in ./config/config.json.

It contains:

  • A list of categories created during the deployment process. Additional categories can be created by the contract administrator using the createCategory function.
  • For each chain id, a quick configuration:
    • "asset": can be "Token" or "Native", select which escrow to use.
    • "token": the address of the token to use. If asset is set to token, and no token address is provided, a mock will be deployed on the fly.
    • "v3": a list of resources from a previous (v3) deployment. This allows previous resources to be automatically available. It also enables score transfer from v3 to v5. [optional]
    • "v5": deployment parameters for the new version. If factory address is set, and no salt is provided, bytes32(0) will be used by default.

If you want to deploy the iExec PoCo V5 smart contracts on a new blockchain, the recommended process is to:

  • Edit the ./config/config.json file as follows:
  • Create a new entry under "chains" with your chain id;
  • Set the asset type depending on your blockchain;
  • If you are using "asset": "Token", provide the address of the token you want to use;
  • Unless you know what you are doing, leave all "v3" resources to Null;
  • Use the factory with the same salt as the other blockchains, and use the same wallet as previous deployments to have the same deployment address on this new blockchain.

Additional configuration & environment variables

Environment variable can be used to alter the configuration of a deployment:

  • SALT: if set, the SALT envvar will overwrite the salt parameter from the config. This can be useful to distinguish different deployments without modifying the config.

Additionally, the migration process will look for some smart contracts before deploying new instances. This is true of the application, dataset and workerpool registries. Thus, if different marketplaces are deployed to the same network, they will share these registries.

Development

Build

The PoCo smart contracts are in the ./contracts folder. Json artifacts, containing the contracts bytecode and ABI can be found in the ./build folder. In case you need to regenerate them, you can use the following command:

npm install
npm run build

Test

Automatic testing

PoCo smart contracts come with a test suite in the ./test folder. You can startup a sandbox blockchain and run the tests using the following command:

npm install
npm run test

Additionally, you can produce a coverage report using the following command:

npm run coverage

The automatic testing command uses the Hardhat network by default to run the tests.

Testing on a custom blockchain

  • Start a blockchain

    • You can either use the Hardhat CLI with the following command:
    npx hardhat node [<any additional arguments>]
    
    • Or run any other blockchain client.
  • [Optional] Update the configuration

    If your blockchain listen to a port that is not 8545, or if the blockchain is on a different node, update the hardhat.config.ts configuration (network ports, accounts with mnemonic, ..) accordingly to the Hardhat Configuration documentation.

  • Run tests

npm run test

Deploy

The iExec PoCo contracts support automated deployment through both command-line interface and GitHub Actions workflows.

Command Line Deployment

You can deploy the smart contracts according to the deploy/0_deploy.ts content. This will automatically save some addresses of the deployed artifacts to the ./deployments folder.

To deploy using the CLI:

  • Make sure you followed the "Configure a deployment" section above
  • Enter your targeted blockchain parameters in hardhat.config.ts
  • Run the deployment using:
npx hardhat deploy --network <your network name>

Example with custom salt:

SALT=0x0000000000000000000000000000000000000000000000000000000000000001 npx hardhat deploy --network hardhat

Manual Verification

To manually verify contracts:

npx hardhat run ./scripts/verify.ts --network <your network name>

This script automatically reads all deployed contract addresses and their constructor arguments from the deployment artifacts and verifies them on the relevant block explorer.

Formatting

Format a specific file or files in a directory:

npm run format <filePath|folderPath>

Render UML diagrams

To render all UML diagrams:

npm run uml

Render only class diagrams

npm run sol-to-uml

Render only .puml files

npm run puml-to-links

Render only storage diagrams

npm run storage-to-diagrams

FAQs

Package last updated on 30 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts