本文整理汇总了Java中org.web3j.abi.FunctionEncoder.encodeConstructor方法的典型用法代码示例。如果您正苦于以下问题:Java FunctionEncoder.encodeConstructor方法的具体用法?Java FunctionEncoder.encodeConstructor怎么用?Java FunctionEncoder.encodeConstructor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.web3j.abi.FunctionEncoder
的用法示例。
在下文中一共展示了FunctionEncoder.encodeConstructor方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendCreateContractTransaction
import org.web3j.abi.FunctionEncoder; //导入方法依赖的package包/类
private String sendCreateContractTransaction() throws Exception {
BigInteger nonce = getNonce(ALICE.getAddress());
String encodedConstructor =
FunctionEncoder.encodeConstructor(Collections.singletonList(new Utf8String(VALUE)));
Transaction transaction = Transaction.createContractTransaction(
ALICE.getAddress(),
nonce,
GAS_PRICE,
GAS_LIMIT,
BigInteger.ZERO,
getGreeterSolidityBinary() + encodedConstructor);
org.web3j.protocol.core.methods.response.EthSendTransaction
transactionResponse = web3j.ethSendTransaction(transaction)
.sendAsync().get();
return transactionResponse.getTransactionHash();
}
示例2: deployContract
import org.web3j.abi.FunctionEncoder; //导入方法依赖的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);
}
示例3: deploy
import org.web3j.abi.FunctionEncoder; //导入方法依赖的package包/类
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, Credentials credentials, 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, credentials, gasPrice, gasLimit, BINARY, encodedConstructor);
}
示例4: sendCreateContractTransaction
import org.web3j.abi.FunctionEncoder; //导入方法依赖的package包/类
private String sendCreateContractTransaction(
Credentials credentials, BigInteger initialSupply) throws Exception {
BigInteger nonce = getNonce(credentials.getAddress());
String encodedConstructor =
FunctionEncoder.encodeConstructor(
Arrays.asList(
new Uint256(initialSupply),
new Utf8String("web3j tokens"),
new Uint8(BigInteger.TEN),
new Utf8String("w3j$")));
RawTransaction rawTransaction = RawTransaction.createContractTransaction(
nonce,
GAS_PRICE,
GAS_LIMIT,
BigInteger.ZERO,
getHumanStandardTokenBinary() + encodedConstructor);
byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
String hexValue = Numeric.toHexString(signedMessage);
EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue)
.sendAsync().get();
return transactionResponse.getTransactionHash();
}
示例5: deploy
import org.web3j.abi.FunctionEncoder; //导入方法依赖的package包/类
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, Credentials credentials, 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, credentials, gasPrice, gasLimit, BINARY, encodedConstructor);
}
示例6: deployContract
import org.web3j.abi.FunctionEncoder; //导入方法依赖的package包/类
private Contract deployContract(TransactionReceipt transactionReceipt)
throws Exception {
prepareTransaction(transactionReceipt);
String encodedConstructor = FunctionEncoder.encodeConstructor(
Arrays.<Type>asList(new Uint256(BigInteger.TEN)));
return TestContract.deployRemoteCall(
TestContract.class, web3j, SampleKeys.CREDENTIALS,
ManagedTransaction.GAS_PRICE, Contract.GAS_LIMIT,
"0xcafed00d", encodedConstructor, BigInteger.ZERO).send();
}
示例7: deploy
import org.web3j.abi.FunctionEncoder; //导入方法依赖的package包/类
public static Future<Greeter> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialValue, Utf8String _greeting) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(_greeting));
return deployAsync(Greeter.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor, initialValue);
}
示例8: deploy
import org.web3j.abi.FunctionEncoder; //导入方法依赖的package包/类
public static RemoteCall<Greeter> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, String _greeting) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.Utf8String(_greeting)));
return deployRemoteCall(Greeter.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor);
}
示例9: deploy
import org.web3j.abi.FunctionEncoder; //导入方法依赖的package包/类
public static Future<OrderBook> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialValue, Utf8String _symbol) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(_symbol));
return deployAsync(OrderBook.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor, initialValue);
}
示例10: deploy
import org.web3j.abi.FunctionEncoder; //导入方法依赖的package包/类
public static Future<Emission> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue, Address contractAddress) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(contractAddress));
return deployAsync(Emission.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor, initialWeiValue);
}
示例11: deploy
import org.web3j.abi.FunctionEncoder; //导入方法依赖的package包/类
public static Future<HumaniqToken> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue, Address founderAddress) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(founderAddress));
return deployAsync(HumaniqToken.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor, initialWeiValue);
}
示例12: deploy
import org.web3j.abi.FunctionEncoder; //导入方法依赖的package包/类
public static RemoteCall<PublicResolver> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, String ensAddr) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(ensAddr)));
return deployRemoteCall(PublicResolver.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor);
}