org.bcos.contract.tools.ARPI_Model Maven / Gradle / Ivy
package org.bcos.contract.tools;
import java.math.BigInteger;
import java.util.List;
import org.bcos.channel.client.Service;
import org.bcos.contract.source.ContractA;
import org.bcos.contract.source.AuthorityFilter;
import org.bcos.contract.source.Group;
import org.bcos.contract.source.SystemProxy;
import org.bcos.contract.source.TransactionFilterChain;
import org.bcos.web3j.abi.datatypes.Address;
import org.bcos.web3j.abi.datatypes.Bool;
import org.bcos.web3j.abi.datatypes.Utf8String;
import org.bcos.web3j.abi.datatypes.generated.Bytes32;
import org.bcos.web3j.abi.datatypes.generated.Uint256;
import org.bcos.web3j.crypto.Credentials;
import org.bcos.web3j.crypto.GenCredential;
import org.bcos.web3j.crypto.Hash;
import org.bcos.web3j.protocol.Web3j;
import org.bcos.web3j.protocol.channel.ChannelEthereumService;
import org.bcos.web3j.protocol.core.methods.response.TransactionReceipt;
import org.bcos.web3j.utils.Numeric;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class ARPI_Model {
static ApplicationContext context;
static TransactionReceipt receipt;
public static BigInteger gasPrice = new BigInteger("99999999999");
public static BigInteger gasLimited = new BigInteger("9999999999999");
public static BigInteger initialValue = new BigInteger("0");
public static void main(String[] args) throws Exception{
context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
Service service = context.getBean(Service.class);
ToolConf toolConf=context.getBean(ToolConf.class);
//getAccount
String account=toolConf.getAccount();
//getPrivKey
String privKey=toolConf.getPrivKey();
service.run();
ChannelEthereumService channelEthereumService = new ChannelEthereumService();
channelEthereumService.setChannelService(service);
Web3j web3j = Web3j.build(channelEthereumService);
Credentials credentials = GenCredential.create(privKey);
SystemProxy systemProxy = SystemProxy.load(toolConf.getSystemProxyAddress(), web3j,credentials , gasPrice,
gasLimited);
//getAddress
String cAAction=SystemContractTools.getAction(systemProxy, "CAAction").toString();
String nodeAction=SystemContractTools.getAction(systemProxy, "NodeAction").toString();
String contractAbiMgr=SystemContractTools.getAction(systemProxy, "ContractAbiMgr").toString();
String configActionAddress=SystemContractTools.getAction(systemProxy, "ConfigAction");
TransactionFilterChain transactionFilterChain=TransactionFilterChain.load(SystemContractTools.getAction(systemProxy, "TransactionFilterChain").toString(), web3j, credentials, gasPrice, gasLimited);
System.out.println("transactionFilterChain"+SystemContractTools.getAction(systemProxy, "TransactionFilterChain").toString());
TransactionReceipt receipt=transactionFilterChain.addFilterAndInfo(new Utf8String("ARPI Filter"), new Utf8String("1.0"), new Utf8String("FISCO BCOS Permission management model")).get();
int filtersLength=transactionFilterChain.getFiltersLength().get().getValue().intValue();
if(filtersLength==0){
System.out.println("Add Filter operation fail");
System.exit(0);
}
System.out.println("Add Filter operation completed, the current number of Filter:"+filtersLength);
AuthorityFilter authorityFilter=AuthorityFilter.load((transactionFilterChain.getFilter(new Uint256(0)).get()).toString(), web3j, credentials, gasLimited, gasLimited);
for(int i=0;i rlist = group.getKeys().get().getValue();
for (int i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy