Search in sources :

Example 1 with EncryptType

use of org.fisco.bcos.web3j.crypto.EncryptType in project web3sdk by FISCO-BCOS.

the class GMErc20Transaction method main.

public static void main(String[] args) throws Exception {
    EncryptType encryptType = new EncryptType(1);
    System.out.println(encryptType.getEncryptType());
    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("300000000");
    Credentials credentials1 = GenCredential.create("a392604efc2fad9c0b3da43b5f698a2e3f270f170d859912be0d54742275c5f6");
    ContractGasProvider contractGasProvider = new StaticGasProvider(gasPrice, gasLimit);
    NewSolTest erc20 = NewSolTest.deploy(web3, credentials1, contractGasProvider).send();
    for (int i = 0; i < 1; i++) {
        System.out.println("####contract address is: " + erc20.getContractAddress());
        erc20.transfer("0x0f49a17d17f82da2a7d92ecf19268274150eaf5e", new BigInteger("100")).send();
        BigInteger oldBalance = erc20.balanceOf("0x0f49a17d17f82da2a7d92ecf19268274150eaf5e").send();
        System.out.println("0x0f49a17d17f82da2a7d92ecf19268274150eaf5e balance" + oldBalance.intValue());
    }
    System.exit(0);
}
Also used : StaticGasProvider(org.fisco.bcos.web3j.tx.gas.StaticGasProvider) 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 2 with EncryptType

use of org.fisco.bcos.web3j.crypto.EncryptType 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 3 with EncryptType

use of org.fisco.bcos.web3j.crypto.EncryptType in project web3sdk by FISCO-BCOS.

the class transferSign method main.

public static void main(String[] args) throws Exception {
    if (args.length < 2) {
        Usage();
    }
    try {
        BigInteger count = new BigInteger(args[0]);
        BigInteger threadCount = new BigInteger(args[1]);
        if (args.length > 2 && args[2].equals("gm")) {
            EncryptType encryptType = new EncryptType(1);
        } else {
            EncryptType encryptType = new EncryptType(0);
        }
        System.out.println((EncryptType.encryptType == EncryptType.ECDSA_TYPE) ? " ===>> normal transfer sign test " : " ===>> sm transfer sign test ");
        logger.info(" transfer tx sign test, txCount: {}, threadCount: {}", count, threadCount);
        DagUserMgr d = new DagUserMgr();
        d.createUser(1000);
        PerformanceDTTest performanceDTTest = new PerformanceDTTest();
        performanceDTTest.setDagUserMgr(d);
        performanceDTTest.userTransferSignTxPerfTest(count, threadCount.intValue());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : EncryptType(org.fisco.bcos.web3j.crypto.EncryptType) BigInteger(java.math.BigInteger)

Aggregations

BigInteger (java.math.BigInteger)3 EncryptType (org.fisco.bcos.web3j.crypto.EncryptType)3 Service (org.fisco.bcos.channel.client.Service)2 Credentials (org.fisco.bcos.web3j.crypto.Credentials)2 Web3j (org.fisco.bcos.web3j.protocol.Web3j)2 ChannelEthereumService (org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService)2 ContractGasProvider (org.fisco.bcos.web3j.tx.gas.ContractGasProvider)2 StaticGasProvider (org.fisco.bcos.web3j.tx.gas.StaticGasProvider)2 ApplicationContext (org.springframework.context.ApplicationContext)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 TransactionReceipt (org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt)1