use of org.fisco.bcos.web3j.tx.gas.StaticGasProvider in project web3sdk by FISCO-BCOS.
the class GMTableTestClient method testTableTest.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void testTableTest(String[] args) throws Exception {
final Resource contractResource = new ClassPathResource("contract.properties");
PropertiesConfiguration prop = new PropertiesConfiguration(contractResource.getFile());
Object addressObj = prop.getProperty("crud_address");
if (addressObj != null) {
contractAddress = (String) addressObj;
} else {
deployTableTest();
}
ContractGasProvider contractGasProvider = new StaticGasProvider(gasPrice, gasLimit);
TableTest tabletest = TableTest.load(contractAddress, web3j, credentials, contractGasProvider);
// create table
if ("create".equals(args[0])) {
create(tabletest);
} else // insert
if ("insert".equals(args[0])) {
insert(args, tabletest);
} else // select
if ("select".equals(args[0])) {
select(args, tabletest);
} else // update
if ("update".equals(args[0])) {
update(args, tabletest);
} else // remove
if ("remove".equals(args[0])) {
remove(args, tabletest);
} else {
System.out.println("\nPlease choose follow commands:\n deploy, create, insert, select, update or remove");
}
}
use of org.fisco.bcos.web3j.tx.gas.StaticGasProvider in project web3sdk by FISCO-BCOS.
the class TableTestClient method testTableTest.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void testTableTest(String[] args) throws Exception {
final Resource contractResource = new ClassPathResource("contract.properties");
PropertiesConfiguration prop = new PropertiesConfiguration(contractResource.getFile());
Object addressObj = prop.getProperty("crud_address");
if (addressObj != null) {
contractAddress = (String) addressObj;
} else {
deployTableTest();
}
ContractGasProvider contractGasProvider = new StaticGasProvider(gasPrice, gasLimit);
TableTest tabletest = TableTest.load(contractAddress, web3j, credentials, contractGasProvider);
// create table
if ("create".equals(args[0])) {
create(tabletest);
} else // insert
if ("insert".equals(args[0])) {
insert(args, tabletest);
} else // select
if ("select".equals(args[0])) {
select(args, tabletest);
} else // update
if ("update".equals(args[0])) {
update(args, tabletest);
} else // remove
if ("remove".equals(args[0])) {
remove(args, tabletest);
} else {
System.out.println("\nPlease choose follow commands:\n deploy, create, insert, select, update or remove");
}
}
use of org.fisco.bcos.web3j.tx.gas.StaticGasProvider in project web3sdk by FISCO-BCOS.
the class GMOkTransaction method main.
public static void main(String[] args) throws Exception {
EncryptType encryptType = new EncryptType(1);
String groupId = "1";
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
Service service = context.getBean(Service.class);
service.run();
System.out.println("===================================================================");
ChannelEthereumService channelEthereumService = new ChannelEthereumService();
channelEthereumService.setChannelService(service);
channelEthereumService.setTimeout(10000);
Web3j web3 = Web3j.build(channelEthereumService, Integer.parseInt(groupId));
BigInteger gasPrice = new BigInteger("300000000");
BigInteger gasLimit = new BigInteger("3000000000");
Credentials credentials1 = GenCredential.create("a392604efc2fad9c0b3da43b5f698a2e3f270f170d859912be0d54742275c5f6");
ContractGasProvider contractGasProvider = new StaticGasProvider(gasPrice, gasLimit);
final Ok okDemo = Ok.deploy(web3, credentials1, contractGasProvider).send();
for (int i = 0; i < 1; i++) {
System.out.println("####contract address is: " + okDemo.getContractAddress());
TransactionReceipt receipt = okDemo.trans(new BigInteger("4")).send();
System.out.println(" balance = " + okDemo.get().send().intValue());
}
System.exit(0);
}
use of org.fisco.bcos.web3j.tx.gas.StaticGasProvider in project web3sdk by FISCO-BCOS.
the class TestTxDecode method sentTx.
public static TransactionReceipt sentTx() throws Exception {
// init the Service
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
Service service = context.getBean(Service.class);
service.run();
ECKeyPair keyPair = Keys.createEcKeyPair();
Credentials credentials = Credentials.create(keyPair);
ChannelEthereumService channelEthereumService = new ChannelEthereumService();
channelEthereumService.setChannelService(service);
service.setGroupId(1);
Web3j web3j = Web3j.build(channelEthereumService, service.getGroupId());
RemoteCall<TableTest> deploy = TableTest.deploy(web3j, credentials, new StaticGasProvider(new BigInteger("30000000"), new BigInteger("30000000")));
TableTest tableTest = deploy.send();
tableTest.create().send();
String name = "fruit";
int item_id = 1;
String item_name = "apple";
RemoteCall<TransactionReceipt> insert = tableTest.insert(name, BigInteger.valueOf(item_id), item_name);
TransactionReceipt txReceipt = insert.send();
return txReceipt;
}
use of org.fisco.bcos.web3j.tx.gas.StaticGasProvider in project web3sdk by FISCO-BCOS.
the class PerformanceDTTest method initialize.
public void initialize(String groupId) throws Exception {
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
Service service = context.getBean(Service.class);
service.setGroupId(Integer.parseInt(groupId));
service.run();
ChannelEthereumService channelEthereumService = new ChannelEthereumService();
channelEthereumService.setChannelService(service);
Web3AsyncThreadPoolSize.web3AsyncCorePoolSize = 3000;
Web3AsyncThreadPoolSize.web3AsyncPoolSize = 2000;
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(500);
Web3j web3 = Web3j.build(channelEthereumService, 15 * 100, scheduledExecutorService, Integer.parseInt(groupId));
Credentials credentials = GenCredential.create();
dagTransfer = DagTransfer.load(dagTransferAddr, web3, credentials, new StaticGasProvider(new BigInteger("30000000"), new BigInteger("30000000")));
transactionManager = Contract.getTheTransactionManager(web3, credentials);
}
Aggregations