Contraect interaction
import com.kryptokrauts.aeternity.sdk.constants.Network;
import com.kryptokrauts.aeternity.sdk.constants.VirtualMachine;
import com.kryptokrauts.aeternity.sdk.service.aeternity.AeternityServiceConfiguration;
import com.kryptokrauts.aeternity.sdk.service.aeternity.AeternityServiceFactory;
import com.kryptokrauts.aeternity.sdk.service.aeternity.impl.AeternityService;
import com.kryptokrauts.contracts.CryptoHamster;
AeternityServiceConfiguration config = AeternityServiceConfiguration
.configure().compilerBaseUrl("http://localhost:3080")
.baseUrl("http://localhost").baseKeyPair(baseKeyPair)
.network(Network.DEVNET).targetVM(VirtualMachine.FATE)
.compile();
// get an instance of the generated contract object
CryptoHamster cryptoHamsterInstance = new CryptoHamster(config, null);
// deploy the contract on the local node
String contractId = cryptoHamsterInstance.deploy();
System.out.println("Deployed contract id - " + contractId );
// call a function of the contract
System.out.println(cryptoHamsterInstance.createHamster("kryptokrauts"));
System.out.println(cryptoHamsterInstance.nameExists("kryptokrauts"));
System.out.println(cryptoHamsterInstance.getHamsterDNA("kryptokrauts"));Last updated
Was this helpful?