Search in sources :

Example 11 with StaticGasProvider

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");
    }
}
Also used : StaticGasProvider(org.fisco.bcos.web3j.tx.gas.StaticGasProvider) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) ContractGasProvider(org.fisco.bcos.web3j.tx.gas.ContractGasProvider) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 12 with StaticGasProvider

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");
    }
}
Also used : StaticGasProvider(org.fisco.bcos.web3j.tx.gas.StaticGasProvider) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) ContractGasProvider(org.fisco.bcos.web3j.tx.gas.ContractGasProvider) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 13 with StaticGasProvider

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);
}
Also used : StaticGasProvider(org.fisco.bcos.web3j.tx.gas.StaticGasProvider) TransactionReceipt(org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt) ChannelEthereumService(org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService) Service(org.fisco.bcos.channel.client.Service) ChannelEthereumService(org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService) ContractGasProvider(org.fisco.bcos.web3j.tx.gas.ContractGasProvider) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) Web3j(org.fisco.bcos.web3j.protocol.Web3j) EncryptType(org.fisco.bcos.web3j.crypto.EncryptType) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) BigInteger(java.math.BigInteger) Credentials(org.fisco.bcos.web3j.crypto.Credentials)

Example 14 with StaticGasProvider

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;
}
Also used : StaticGasProvider(org.fisco.bcos.web3j.tx.gas.StaticGasProvider) ECKeyPair(org.fisco.bcos.web3j.crypto.ECKeyPair) TransactionReceipt(org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt) ChannelEthereumService(org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService) Service(org.fisco.bcos.channel.client.Service) ChannelEthereumService(org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Web3j(org.fisco.bcos.web3j.protocol.Web3j) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) BigInteger(java.math.BigInteger) Credentials(org.fisco.bcos.web3j.crypto.Credentials)

Example 15 with StaticGasProvider

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);
}
Also used : StaticGasProvider(org.fisco.bcos.web3j.tx.gas.StaticGasProvider) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Web3j(org.fisco.bcos.web3j.protocol.Web3j) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Service(org.fisco.bcos.channel.client.Service) ChannelEthereumService(org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService) BigInteger(java.math.BigInteger) ChannelEthereumService(org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService) Credentials(org.fisco.bcos.web3j.crypto.Credentials)

Aggregations

StaticGasProvider (org.fisco.bcos.web3j.tx.gas.StaticGasProvider)16 BigInteger (java.math.BigInteger)10 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)6 ContractGasProvider (org.fisco.bcos.web3j.tx.gas.ContractGasProvider)6 ClassPathResource (org.springframework.core.io.ClassPathResource)6 Resource (org.springframework.core.io.Resource)6 Service (org.fisco.bcos.channel.client.Service)5 Credentials (org.fisco.bcos.web3j.crypto.Credentials)5 ChannelEthereumService (org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService)5 TransactionReceipt (org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt)5 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)5 Web3j (org.fisco.bcos.web3j.protocol.Web3j)4 ApplicationContext (org.springframework.context.ApplicationContext)4 Random (java.util.Random)3 TransactionException (org.fisco.bcos.web3j.protocol.exceptions.TransactionException)3 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)3 RateLimiter (com.google.common.util.concurrent.RateLimiter)2 Date (java.util.Date)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2