All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ethereum.vm.program.NewAccountCreateAdapter Maven / Gradle / Ivy

Go to download

Java implementation of the Ethereum protocol adapted to use for Hedera Smart Contract Service

The newest version!
package org.ethereum.vm.program;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.ethereum.core.Repository;
import org.ethereum.crypto.HashUtil;

public class NewAccountCreateAdapter {
    private Map> createdContracts = new HashMap<>();

    public byte[] calculateNewAddress(byte[] ownerAddress , Repository track) {
        byte[] nonce = track.getNonce(ownerAddress).toByteArray();
        return HashUtil.calcNewAddr(ownerAddress, nonce);
    }

    public void addCreatedContract(byte[] newContractAddress, byte[] creatorAddress, Repository track) {
        List contractsForCreator = createdContracts.get(creatorAddress);
        if (contractsForCreator == null) {
            contractsForCreator = new ArrayList();
        }
        contractsForCreator.add(newContractAddress);
        createdContracts.put(creatorAddress, contractsForCreator);
    }
    
    public Map> getCreatedContracts() {
        return createdContracts;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy