All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bcos.web3j.console.Web3RpcApi Maven / Gradle / Ivy

There is a newer version: 2.6.6
Show newest version
package org.bcos.web3j.console;

import java.math.BigInteger;
import java.util.List;

import org.bcos.web3j.protocol.ObjectMapperFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.bcos.channel.client.Service;
import org.bcos.web3j.protocol.Web3j;
import org.bcos.web3j.protocol.channel.ChannelEthereumService;
import org.bcos.web3j.protocol.core.DefaultBlockParameter;
import org.bcos.web3j.protocol.core.methods.response.EthBlock;
import org.bcos.web3j.protocol.core.methods.response.Transaction;
import org.bcos.web3j.protocol.core.methods.response.TransactionReceipt;

public class Web3RpcApi {
	
	private static BigInteger transactionCount = BigInteger.valueOf(0);
	private static BigInteger bigBlockHeight = BigInteger.valueOf(0);
	private static BigInteger bigPbftView= BigInteger.valueOf(0);
	private static EthBlock.Block block=null;
	private static BigInteger transactionIndex=BigInteger.valueOf(0);
	private static Transaction transaction=null;
	private static String transactionHash=null;

	public static void main(String[] args)  {
		System.out.println("==================================================================="+"\n"+"\n");
		ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
		Service service = context.getBean(Service.class);
        try {
			service.run();
		} catch (Exception e) {
			System.out.println(e);
		}
        ChannelEthereumService channelEthereumService = new ChannelEthereumService();
        channelEthereumService.setChannelService(service);
        Web3j web3j = Web3j.build(channelEthereumService);
        
        try {
        	switch (args[0]) {
        	
        	case "eth_accounts" :
        		
        		List list=web3j.ethAccounts().send().getAccounts();
        		if(list.size()==0){
        			System.out.println("account is null");
        		}
        		if(list.size()>0){
        			for (int n=0;n




© 2015 - 2024 Weber Informatics LLC | Privacy Policy