You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
contractgreeter{/* Define variable greeting of the type string */stringgreeting;/* This runs when the contract is executed */functiongreeter(string_greeting)public{greeting=_greeting;}/* Main function */functiongreet()constantreturns(string){returngreeting;}/* Update greeting */functionnewGreeting(string_greeting)publicreturns(string){greeting=_greeting;returngreeting;}}
Etherspace generates an implementation of Greeter interface.
You can than use greeter to interact with Smart Contract on Ethereum!
// Kotlinval etherSpace =EtherSpace.build {
provider ="https://rinkeby.infura.io/"// Or your local node
credentials =Credentials(YOUR_PRIVATE_KEY_OR_WALLET)
}
var greeter = etherSpace.create(SMART_CONTRACT_ADDRESS, Greeter::class.java)
val hash = greeter.newGreeting("Hello World")
val receipt = hash.requestTransactionReceipt<TransactionReceipt>()
println(greeter.greet()) // Should be "Hello World"
// JavaEtherSpaceetherSpace = newEtherSpace.Builder()
.provider("https://rinkeby.infura.io/") // Or your local node
.credentials(newCredentials(YOUR_PRIVATE_KEY_OR_WALLET))
.build();
Greetergreeter = etherSpace.create(SMART_CONTRACT_ADDRESS, Greeter.class);
TransactionHashhash = greeter.newGreeting("Hello World");
TransactionReceiptreceipt = hash.requestTransactionReceipt();
System.out.println(greeter.greet()); // Should be "Hello World"