org.ethereum.vm.program.NewAccountCreateAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ethereumj-core Show documentation
Show all versions of ethereumj-core Show documentation
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;
}
}