Search in sources :

Example 41 with TransactionReceipt

use of org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt 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)

Aggregations

TransactionReceipt (org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt)41 BigInteger (java.math.BigInteger)18 Service (org.fisco.bcos.channel.client.Service)10 Credentials (org.fisco.bcos.web3j.crypto.Credentials)10 Web3j (org.fisco.bcos.web3j.protocol.Web3j)10 ChannelEthereumService (org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService)10 ApplicationContext (org.springframework.context.ApplicationContext)10 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)10 RateLimiter (com.google.common.util.concurrent.RateLimiter)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 TransactionException (org.fisco.bcos.web3j.protocol.exceptions.TransactionException)9 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)9 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)8 Random (java.util.Random)6 Utf8String (org.fisco.bcos.web3j.abi.datatypes.Utf8String)5 StaticGasProvider (org.fisco.bcos.web3j.tx.gas.StaticGasProvider)5 List (java.util.List)4 PrecompileMessageException (org.fisco.bcos.web3j.precompile.exception.PrecompileMessageException)3 Test (org.junit.Test)3 IOException (java.io.IOException)2