当前位置: 首页>>代码示例>>Java>>正文


Java FunctionEncoder.encodeConstructor方法代码示例

本文整理汇总了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();
}
 
开发者ID:web3j,项目名称:web3j,代码行数:21,代码来源:GreeterContractIT.java

示例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);
}
 
开发者ID:papyrusglobal,项目名称:state-channels,代码行数:37,代码来源:DeployService.java

示例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);
}
 
开发者ID:web3j,项目名称:quorum,代码行数:8,代码来源:HumanStandardToken.java

示例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();
}
 
开发者ID:web3j,项目名称:web3j,代码行数:28,代码来源:HumanStandardTokenIT.java

示例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);
}
 
开发者ID:web3j,项目名称:web3j,代码行数:8,代码来源:HumanStandardToken.java

示例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();
}
 
开发者ID:web3j,项目名称:web3j,代码行数:14,代码来源:ContractTest.java

示例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);
}
 
开发者ID:matthiaszimmermann,项目名称:web3j_demo,代码行数:5,代码来源:Greeter.java

示例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);
}
 
开发者ID:web3j,项目名称:quorum,代码行数:5,代码来源:Greeter.java

示例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);
}
 
开发者ID:BSI-Business-Systems-Integration-AG,项目名称:trading-network,代码行数:5,代码来源:OrderBook.java

示例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);
}
 
开发者ID:humaniq,项目名称:humaniq-android,代码行数:5,代码来源:Emission.java

示例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);
}
 
开发者ID:humaniq,项目名称:humaniq-android,代码行数:5,代码来源:HumaniqToken.java

示例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);
}
 
开发者ID:web3j,项目名称:web3j,代码行数:5,代码来源:PublicResolver.java


注:本文中的org.web3j.abi.FunctionEncoder.encodeConstructor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。