A Parallelizable Ethereum Example

This example comes from Solidity's official document, Subcurrency Example. It implements a simple cryptocurrency, with two main functions:

  • Mint

  • Send


It is clear that both of the two functions modify the balances only. The minting function modifies the account balance of a recipient, while the transferring changes the account balances of both parties.

This Ethereum contract is naturally parallelizable by itself, two transactions calling mint can be executed in parallel because they won't access any shared states. As long as they're not targeting the same recipient. This applies to coins transfers too.

pragma solidity >=0.8.0 <0.9.0;

contract Coin {
    // The keyword "public" makes variables
    // accessible from other contracts
    address public minter;
    mapping (address => uint) public balances;

    // Events allow clients to react to specific
    // contract changes you declare
    event Sent(address from, address to, uint amount);

    // Constructor code is only run when the contract
    // is created
    constructor() {
        minter = msg.sender;

    // Sends an amount of newly created coins to an address
    // Can only be called by the contract creator
    function mint(address receiver, uint amount) public {
        require(msg.sender == minter);
        require(amount < 1e60);
        balances[receiver] += amount;

    // Sends an amount of existing coins
    // from any caller to an address
    function send(address receiver, uint amount) public {
        require(amount <= balances[msg.sender], "Insufficient balance.");
        balances[msg.sender] -= amount;
        balances[receiver] += amount;
        emit Sent(msg.sender, receiver, amount);
    // Additional function to query the balance of a specific address.
    function getter(address addr) public view returns(uint256) {
        return balances[addr];

Parallel Caller

The SubcurrencyCaller contract is designed to demonstrate the parallel processing capability of Arcology's multiprocessing feature. It interacts with the Subcurrency contract, which is a simplified version of a token contract named Coin.

The SubcurrencyCaller contract utilizes Arcology's Multiprocess library to perform parallel processing of multiple minting transactions on the Subcurrency contract. By using Multiprocess, it is able to submit and execute multiple minting transactions concurrently, greatly improving the overall efficiency and reducing the processing time.

The Multiprocess library provides a convenient way to execute multiple transactions in parallel within a single smart contract call. It allows the contract to bundle multiple transactions together and execute them simultaneously, taking advantage of Arcology's parallel processing capabilities.

Note: The example highlights the main features and applications of Arcology's multiprocessing capability. It demonstrates how Arcology's technology can enhance the execution of smart contracts and provide significant benefits in terms of scalability and efficiency.

Code Analysis

  1. Parallel Minting Transactions: In the call function of the SubcurrencyCaller contract, four minting transactions are added to the Multiprocess queue. These transactions are designed to mint tokens for four different addresses: Alice, Bob, Carol, and Dave.

  2. Execution and Verification: After adding the minting transactions to the Multiprocess queue using mp.push(), the contract checks if the number of transactions in the queue is equal to 4 by using mp.length(). This ensures that all four minting transactions have been successfully added to the queue.

  3. Parallel Execution: The function is then called, which executes all the minting transactions in parallel. Arcology's parallel processing capability allows these transactions to be processed simultaneously, reducing the overall execution time and gas cost.

  4. Verification of Minted Balances: After the parallel execution, the contract verifies the balances of the four addresses by calling the getter function of the Subcurrency contract. This demonstrates that the transactions were executed correctly, and the minted amounts were applied to the corresponding addresses.

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.19;

import "../../lib/multiprocess/Multiprocess.sol";
import "./Subcurrency.sol";

contract SubcurrencyCaller {
    function call(address coin) public{        
        address Alice = 0x1111111110123456789012345678901234567890;
        address Bob = 0x2222222220123456789012345678901234567890;
        address Carol = 0x4444444890123456789012345678901234567890;
        address Dave = 0x3333337890123456789012345678901234567890;
        Multiprocess mp = new Multiprocess(4); // Number of threads
        mp.push(100000, address(coin), abi.encodeWithSignature("mint(address,uint256)", Alice, 1111));
        mp.push(100000, address(coin), abi.encodeWithSignature("mint(address,uint256)", Bob, 2222));
        mp.push(100000, address(coin), abi.encodeWithSignature("mint(address,uint256)", Carol, 3333));
        mp.push(100000, address(coin), abi.encodeWithSignature("mint(address,uint256)", Dave, 4444));
        require(mp.length() == 4);; // Start parallel processing

        require(Coin(coin).getter(Alice) == 1111);
        require(Coin(coin).getter(Bob) == 2222);
        require(Coin(coin).getter(Carol) == 3333);
        require(Coin(coin).getter(Dave) == 4444);


The SubcurrencyCaller contract showcases the potential applications of Arcology's parallel processing capability in smart contract development. By enabling parallel execution of transactions, Arcology can significantly enhance the scalability and efficiency of smart contracts.

Last updated