本文整理汇总了Java中org.web3j.tx.TransactionManager类的典型用法代码示例。如果您正苦于以下问题:Java TransactionManager类的具体用法?Java TransactionManager怎么用?Java TransactionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionManager类属于org.web3j.tx包,在下文中一共展示了TransactionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callHash
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
private byte[] callHash(String name, Type...parameters) throws InterruptedException, ExecutionException {
Function function = new Function(name,
Arrays.asList(parameters),
Arrays.asList(new TypeReference<Bytes32>() {})
);
String encodedFunction = FunctionEncoder.encode(function);
TransactionManager transactionManager = cfg.getTransactionManager(cfg.getMainAddress());
String channelLibraryAddress = contractsProperties.getAddress().get("ChannelLibrary").toString();
org.web3j.protocol.core.methods.response.EthCall ethCall = web3j.ethCall(
Transaction.createEthCallTransaction(
transactionManager.getFromAddress(), channelLibraryAddress, encodedFunction),
DefaultBlockParameterName.LATEST)
.sendAsync().get();
String value = ethCall.getValue();
List<Type> list = FunctionReturnDecoder.decode(value, function.getOutputParameters());
return ((Bytes32) list.get(0)).getValue();
}
示例2: create
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
private <T extends Contract> T create(Class<T> type, TransactionReceipt rc) {
try {
Constructor<T> constructor = type.getDeclaredConstructor(
String.class,
Web3j.class, TransactionManager.class,
BigInteger.class, BigInteger.class);
constructor.setAccessible(true);
T contract = constructor.newInstance(null, web3j, transactionManager, rpcProperties.getGasPrice(), rpcProperties.getGasLimit());
contract.setContractAddress(rc.getContractAddress());
contract.setTransactionReceipt(rc);
return contract;
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
示例3: refill
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
public void refill(BigDecimal minBalance, String address, Supplier<TransactionManager> managerSupplier) throws InterruptedException, ExecutionException {
BigDecimal balance = ethereumService.getBalance(address, Convert.Unit.ETHER);
log.info("Balance of {} is {}", address, balance);
if (minBalance != null && minBalance.signum() > 0) {
if (balance.compareTo(minBalance) < 0) {
TransactionManager manager = managerSupplier.get();
log.info("Refill {} ETH from {} to {}", minBalance, manager.getFromAddress(), address);
try {
new Transfer(web3j, manager).sendFunds(address, minBalance, Convert.Unit.ETHER).send();
} catch (Exception e) {
log.warn("Refill failed", e);
}
log.info("Balance after refill of {} is {}", address, ethereumService.getBalance(address, Convert.Unit.ETHER));
}
}
}
示例4: generateJavaFiles
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
void generateJavaFiles(
String contractName, String bin, List<AbiDefinition> abi, String destinationDir,
String basePackageName, Map<String, String> addresses)
throws IOException, ClassNotFoundException {
String className = Strings.capitaliseFirstLetter(contractName);
TypeSpec.Builder classBuilder = createClassBuilder(className, bin);
classBuilder.addMethod(buildConstructor(Credentials.class, CREDENTIALS));
classBuilder.addMethod(buildConstructor(TransactionManager.class,
TRANSACTION_MANAGER));
classBuilder.addMethods(
buildFunctionDefinitions(className, classBuilder, abi));
classBuilder.addMethod(buildLoad(className, Credentials.class, CREDENTIALS));
classBuilder.addMethod(buildLoad(className, TransactionManager.class,
TRANSACTION_MANAGER));
addAddressesSupport(classBuilder, addresses);
write(basePackageName, classBuilder.build(), destinationDir);
}
示例5: ContractsManager
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
public ContractsManager(String fromAddress, EthRpcProperties rpcProperties, Web3j web3j, ContractsProperties contractsProperties, TransactionManager transactionManager) {
this.web3j = web3j;
this.rpcProperties = rpcProperties;
this.transactionManager = transactionManager;
this.contractsProperties = contractsProperties;
registry = loadPredeployedContract(EndpointRegistryContract.class);
token = loadPredeployedContract(StandardToken.class, "Token");
this.fromAddress = new Address(fromAddress);
tokenService = new TokenService(token, this.fromAddress);
channelManager = loadPredeployedContract(ChannelManagerContract.class);
}
示例6: load
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
public <C extends Contract> C load(Class<C> contractClass, Address address) {
try {
//String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit
Method method = contractClass.getDeclaredMethod("load", String.class, Web3j.class, TransactionManager.class, BigInteger.class, BigInteger.class);
Object contract = method.invoke(null, address.toString(), web3j, transactionManager, rpcProperties.getGasPrice(), rpcProperties.getGasLimit());
return contractClass.cast(contract);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
示例7: deployContract
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
public Address deployContract(TransactionManager transactionManager, String binary, Map<String, Address> libraries, Type... constructorArgs) throws IOException, InterruptedException, TransactionException {
ContractLinker linker = new ContractLinker(binary);
if (libraries != null && !libraries.isEmpty()) {
libraries.forEach(linker::link);
}
linker.assertLinked();
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(constructorArgs));
String data = linker.getBinary() + encodedConstructor;
EthSendTransaction transactionResponse = transactionManager.sendTransaction(
properties.getGasPrice(), properties.getGasLimit(), null, data, BigInteger.ZERO);
if (transactionResponse.hasError()) {
throw new RuntimeException("Error processing transaction request: "
+ transactionResponse.getError().getMessage());
}
String transactionHash = transactionResponse.getTransactionHash();
Optional<TransactionReceipt> receiptOptional =
sendTransactionReceiptRequest(transactionHash, web3j);
long millis = properties.getSleep().toMillis();
int attempts = properties.getAttempts();
for (int i = 0; i < attempts; i++) {
if (!receiptOptional.isPresent()) {
Thread.sleep(millis);
receiptOptional = sendTransactionReceiptRequest(transactionHash, web3j);
} else {
String contractAddress = receiptOptional.get().getContractAddress();
return new Address(contractAddress);
}
}
throw new TransactionException("Transaction receipt was not generated after " + (millis * attempts / 1000)
+ " seconds for transaction: " + transactionHash);
}
示例8: deploy
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger _initialAmount, String _tokenName, BigInteger _decimalUnits, String _tokenSymbol) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_initialAmount),
new org.web3j.abi.datatypes.Utf8String(_tokenName),
new org.web3j.abi.datatypes.generated.Uint8(_decimalUnits),
new org.web3j.abi.datatypes.Utf8String(_tokenSymbol)));
return deployRemoteCall(HumanStandardToken.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor);
}
示例9: deploy
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger _initialAmount, String _tokenName, BigInteger _decimalUnits, String _tokenSymbol) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_initialAmount),
new org.web3j.abi.datatypes.Utf8String(_tokenName),
new org.web3j.abi.datatypes.generated.Uint8(_decimalUnits),
new org.web3j.abi.datatypes.Utf8String(_tokenSymbol)));
return deployRemoteCall(HumanStandardToken.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor);
}
示例10: ModumToken
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
private ModumToken(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
}
示例11: deploy
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
public static Future<ModumToken> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue) {
return deployAsync(ModumToken.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "", initialWeiValue);
}
示例12: load
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
public static ModumToken load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
return new ModumToken(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
}
示例13: getTransactionManager
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
public TransactionManager getTransactionManager() {
return transactionManager;
}
示例14: createManager
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
public ContractsManager createManager(TransactionManager transactionManager, String fromAddress) {
return new ContractsManager(fromAddress, ethProperties.getRpc(), web3j, contractsProperties, transactionManager);
}
示例15: Echo_sol_Echo
import org.web3j.tx.TransactionManager; //导入依赖的package包/类
private Echo_sol_Echo(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
}