Skip to content

Instantly share code, notes, and snippets.

@kelsos
Created October 3, 2017 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kelsos/f4d8e290620cb5ca1c27746c8dc62479 to your computer and use it in GitHub Desktop.
Save kelsos/f4d8e290620cb5ca1c27746c8dc62479 to your computer and use it in GitHub Desktop.
Abigen Result
// This file is an automatically generated Java binding. Do not modify as any
// change will likely be lost upon the next re-generation!
package io.sikorka.android.contract;
import org.ethereum.geth.*;
import org.ethereum.geth.internal.*;
public class SikorkaRegistry {
// ABI is the input ABI used to generate the binding from.
public final static String ABI = "[{\"constant\":true,\"inputs\":[{\"name\":\"channel\",\"type\":\"address\"}],\"name\":\"contractExists\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"contract_address\",\"type\":\"address\"},{\"name\":\"latitude\",\"type\":\"uint256\"},{\"name\":\"longitude\",\"type\":\"uint256\"}],\"name\":\"addContract\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getContractAddresses\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"contract_address\",\"type\":\"address\"}],\"name\":\"removeContract\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"sikorka_contracts\",\"outputs\":[{\"name\":\"contract_address\",\"type\":\"address\"},{\"name\":\"latitude\",\"type\":\"uint256\"},{\"name\":\"longitude\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"contract_address\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"latitude\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"longitude\",\"type\":\"uint256\"}],\"name\":\"ContractAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"contract_address\",\"type\":\"address\"}],\"name\":\"ContractRemoved\",\"type\":\"event\"}]";
// BYTECODE is the compiled bytecode used for deploying new contracts.
public final static byte[] BYTECODE = "0x6060604052341561000f57600080fd5b6105198061001e6000396000f300606060405263ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416637709bc7881146100685780638f33221e1461009b578063953874d2146100c2578063c375c2ef14610128578063f7d2b1011461014757600080fd5b341561007357600080fd5b610087600160a060020a0360043516610193565b604051901515815260200160405180910390f35b34156100a657600080fd5b6100c0600160a060020a036004351660243560443561019b565b005b34156100cd57600080fd5b6100d56102bd565b60405160208082528190810183818151815260200191508051906020019060200280838360005b838110156101145780820151838201526020016100fc565b505050509050019250505060405180910390f35b341561013357600080fd5b6100c0600160a060020a036004351661035d565b341561015257600080fd5b61015d600435610429565b6040518084600160a060020a0316600160a060020a03168152602001838152602001828152602001935050505060405180910390f35b6000903b1190565b60006101a684610193565b15156101b157600080fd5b60008054600181016101c38382610464565b9160005260206000209060030201600060606040519081016040908152600160a060020a03891682526020820188905281018690529190508151815473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0391909116178155602082015181600101556040820151600290910155505060008054600160a060020a0386168252600160205260409182902081905591507f416a85ad46a79c0c8942d936d910a83796d3d0d516990461d23b9f19073715ca90859085908590518084600160a060020a0316600160a060020a03168152602001838152602001828152602001935050505060405180910390a150505050565b6102c5610495565b60006102cf610495565b6000546040518059106102df5750595b90808252806020026020018201604052509050600091505b60005482101561035757600080548390811061030f57fe5b6000918252602090912060039091020154600160a060020a031681838151811061033557fe5b600160a060020a039092166020928302909101909101526001909101906102f7565b92915050565b600160a060020a03811660009081526001602052604090205480151561038257600080fd5b60008054600019830190811061039457fe5b600091825260208083206003909202909101805473ffffffffffffffffffffffffffffffffffffffff1916815560018082018490556002909101839055600160a060020a038516835290526040808220919091557f8d30d41865a0b811b9545d879520d2dde9f4cc49e4241f486ad9752bc904b56590839051600160a060020a03909116815260200160405180910390a15050565b600080548290811061043757fe5b6000918252602090912060039091020180546001820154600290920154600160a060020a03909116925083565b8154818355818115116104905760030281600302836000526020600020918201910161049091906104a7565b505050565b60206040519081016040526000815290565b6104ea91905b808211156104e657805473ffffffffffffffffffffffffffffffffffffffff1916815560006001820181905560028201556003016104ad565b5090565b905600a165627a7a723058204318bf2678a89af559fca17f449eb1dc47dc9b2fba736dcd1ad8e7e90d64036e0029".getBytes();
// deploy deploys a new Ethereum contract, binding an instance of SikorkaRegistry to it.
public static SikorkaRegistry deploy(TransactOpts auth, EthereumClient client) throws Exception {
Interfaces args = Geth.newInterfaces(0);
return new SikorkaRegistry(Geth.deployContract(auth, ABI, BYTECODE, client, args));
}
// Internal constructor used by contract deployment.
private SikorkaRegistry(BoundContract deployment) {
this.Address = deployment.getAddress();
this.Deployer = deployment.getDeployer();
this.Contract = deployment;
}
// Ethereum address where this contract is located at.
public final Address Address;
// Ethereum transaction in which this contract was deployed (if known!).
public final Transaction Deployer;
// Contract instance bound to a blockchain address.
private final BoundContract Contract;
// Creates a new instance of SikorkaRegistry, bound to a specific deployed contract.
public SikorkaRegistry(Address address, EthereumClient client) throws Exception {
this(Geth.bindContract(address, ABI, client));
}
// contractExists is a free data retrieval call binding the contract method 0x7709bc78.
//
// Solidity: function contractExists(channel address) constant returns(bool)
public bool contractExists(CallOpts opts, Address channel) throws Exception {
Interfaces args = Geth.newInterfaces(1);
args.set(0, Geth.newInterface()); args.get(0).setAddress(channel);
Interfaces results = Geth.newInterfaces(1);
Interface result0 = Geth.newInterface(); result0.setDefaultBool(); results.set(0, result0);
if (opts == null) {
opts = Geth.newCallOpts();
}
this.Contract.call(opts, results, "contractExists", args);
return results.get(0).getBool();
}
// getContractAddresses is a free data retrieval call binding the contract method 0x953874d2.
//
// Solidity: function getContractAddresses() constant returns(address[])
public Addresses getContractAddresses(CallOpts opts) throws Exception {
Interfaces args = Geth.newInterfaces(0);
Interfaces results = Geth.newInterfaces(1);
Interface result0 = Geth.newInterface(); result0.setDefaultAddresses(); results.set(0, result0);
if (opts == null) {
opts = Geth.newCallOpts();
}
this.Contract.call(opts, results, "getContractAddresses", args);
return results.get(0).getAddresses();
}
// Sikorka_contractsResults is the output of a call to sikorka_contracts.
public class Sikorka_contractsResults {
public Address Contract_address;
public BigInt Latitude;
public BigInt Longitude;
}
// sikorka_contracts is a free data retrieval call binding the contract method 0xf7d2b101.
//
// Solidity: function sikorka_contracts( uint256) constant returns(contract_address address, latitude uint256, longitude uint256)
public Sikorka_contractsResults sikorka_contracts(CallOpts opts, BigInt arg0) throws Exception {
Interfaces args = Geth.newInterfaces(1);
args.set(0, Geth.newInterface()); args.get(0).setBigInt(arg0);
Interfaces results = Geth.newInterfaces(3);
Interface result0 = Geth.newInterface(); result0.setDefaultAddress(); results.set(0, result0);
Interface result1 = Geth.newInterface(); result1.setDefaultBigInt(); results.set(1, result1);
Interface result2 = Geth.newInterface(); result2.setDefaultBigInt(); results.set(2, result2);
if (opts == null) {
opts = Geth.newCallOpts();
}
this.Contract.call(opts, results, "sikorka_contracts", args);
Sikorka_contractsResults result = new Sikorka_contractsResults();
result.Contract_address = results.get(0).getAddress();
result.Latitude = results.get(1).getBigInt();
result.Longitude = results.get(2).getBigInt();
return result;
}
// addContract is a paid mutator transaction binding the contract method 0x8f33221e.
//
// Solidity: function addContract(contract_address address, latitude uint256, longitude uint256) returns()
public Transaction addContract(TransactOpts opts, Address contract_address, BigInt latitude, BigInt longitude) throws Exception {
Interfaces args = Geth.newInterfaces(3);
args.set(0, Geth.newInterface()); args.get(0).setAddress(contract_address);
args.set(1, Geth.newInterface()); args.get(1).setBigInt(latitude);
args.set(2, Geth.newInterface()); args.get(2).setBigInt(longitude);
return this.Contract.transact(opts, "addContract" , args);
}
// removeContract is a paid mutator transaction binding the contract method 0xc375c2ef.
//
// Solidity: function removeContract(contract_address address) returns()
public Transaction removeContract(TransactOpts opts, Address contract_address) throws Exception {
Interfaces args = Geth.newInterfaces(1);
args.set(0, Geth.newInterface()); args.get(0).setAddress(contract_address);
return this.Contract.transact(opts, "removeContract" , args);
}
}
public class Utils {
// ABI is the input ABI used to generate the binding from.
public final static String ABI = "[{\"constant\":true,\"inputs\":[{\"name\":\"channel\",\"type\":\"address\"}],\"name\":\"contractExists\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]";
// BYTECODE is the compiled bytecode used for deploying new contracts.
public final static byte[] BYTECODE = "0x6060604052341561000f57600080fd5b60ac8061001d6000396000f300606060405263ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416637709bc788114603b57600080fd5b3415604557600080fd5b606473ffffffffffffffffffffffffffffffffffffffff600435166078565b604051901515815260200160405180910390f35b6000903b11905600a165627a7a72305820aeb2afd5933f3f4bc03ab6febb39bd7f91d5ddc47ed0158c055987accc7c11a80029".getBytes();
// deploy deploys a new Ethereum contract, binding an instance of Utils to it.
public static Utils deploy(TransactOpts auth, EthereumClient client) throws Exception {
Interfaces args = Geth.newInterfaces(0);
return new Utils(Geth.deployContract(auth, ABI, BYTECODE, client, args));
}
// Internal constructor used by contract deployment.
private Utils(BoundContract deployment) {
this.Address = deployment.getAddress();
this.Deployer = deployment.getDeployer();
this.Contract = deployment;
}
// Ethereum address where this contract is located at.
public final Address Address;
// Ethereum transaction in which this contract was deployed (if known!).
public final Transaction Deployer;
// Contract instance bound to a blockchain address.
private final BoundContract Contract;
// Creates a new instance of Utils, bound to a specific deployed contract.
public Utils(Address address, EthereumClient client) throws Exception {
this(Geth.bindContract(address, ABI, client));
}
// contractExists is a free data retrieval call binding the contract method 0x7709bc78.
//
// Solidity: function contractExists(channel address) constant returns(bool)
public bool contractExists(CallOpts opts, Address channel) throws Exception {
Interfaces args = Geth.newInterfaces(1);
args.set(0, Geth.newInterface()); args.get(0).setAddress(channel);
Interfaces results = Geth.newInterfaces(1);
Interface result0 = Geth.newInterface(); result0.setDefaultBool(); results.set(0, result0);
if (opts == null) {
opts = Geth.newCallOpts();
}
this.Contract.call(opts, results, "contractExists", args);
return results.get(0).getBool();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment