Java Code Examples for org.web3j.abi.FunctionEncoder#encodeConstructor()

The following examples show how to use org.web3j.abi.FunctionEncoder#encodeConstructor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GreeterContractIT.java    From web3j with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 2
Source File: HumanStandardToken.java    From web3j with Apache License 2.0 5 votes vote down vote up
@Deprecated
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);
}
 
Example 3
Source File: Greeter.java    From jbpm-work-items with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 4
Source File: BlindAuction.java    From web3j with Apache License 2.0 5 votes vote down vote up
@Deprecated
public static RemoteCall<BlindAuction> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger _biddingTime, BigInteger _revealTime, String _beneficiary) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_biddingTime),
            new org.web3j.abi.datatypes.generated.Uint256(_revealTime), 
            new org.web3j.abi.datatypes.Address(_beneficiary)));
    return deployRemoteCall(BlindAuction.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor);
}
 
Example 5
Source File: HumanStandardToken.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, TransactionManager transactionManager, GasProvider contractGasProvider,
		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, contractGasProvider, BINARY, encodedConstructor);
}
 
Example 6
Source File: ContractTest.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
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, getVerifiedTransactionManager(SampleKeys.CREDENTIALS),
            ManagedTransaction.GAS_PRICE, Contract.GAS_LIMIT,
            "0xcafed00d", encodedConstructor, BigInteger.ZERO).send();
}
 
Example 7
Source File: HumanStandardToken.java    From web3j with Apache License 2.0 5 votes vote down vote up
@Deprecated
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);
}
 
Example 8
Source File: HumanStandardToken.java    From web3j-quorum with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider, 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, contractGasProvider, BINARY, encodedConstructor);
}
 
Example 9
Source File: Greeter.java    From web3j-quorum with Apache License 2.0 4 votes vote down vote up
@Deprecated
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);
}
 
Example 10
Source File: PublicResolver.java    From web3j with Apache License 2.0 4 votes vote down vote up
public static RemoteCall<PublicResolver> deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider, String ensAddr) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(ensAddr)));
    return deployRemoteCall(PublicResolver.class, web3j, transactionManager, contractGasProvider, BINARY, encodedConstructor);
}
 
Example 11
Source File: PublicResolver.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
public static RemoteCall<PublicResolver> deploy(Web3j web3j, TransactionManager transactionManager, 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, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor);
}
 
Example 12
Source File: Greeter.java    From web3j with Apache License 2.0 4 votes vote down vote up
@Deprecated
public static RemoteCall<Greeter> deploy(Web3j web3j, TransactionManager transactionManager, 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, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor);
}
 
Example 13
Source File: BlindAuction.java    From web3j with Apache License 2.0 4 votes vote down vote up
public static RemoteCall<BlindAuction> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, BigInteger _biddingTime, BigInteger _revealTime, String _beneficiary) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_biddingTime),
            new org.web3j.abi.datatypes.generated.Uint256(_revealTime), 
            new org.web3j.abi.datatypes.Address(_beneficiary)));
    return deployRemoteCall(BlindAuction.class, web3j, credentials, contractGasProvider, BINARY, encodedConstructor);
}
 
Example 14
Source File: ComplexStorage.java    From web3j with Apache License 2.0 4 votes vote down vote up
public static RemoteCall<ComplexStorage> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, Foo _foo, Bar _bar) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(_foo,
            _bar));
    return deployRemoteCall(ComplexStorage.class, web3j, credentials, contractGasProvider, BINARY, encodedConstructor);
}
 
Example 15
Source File: Greeter.java    From web3j with Apache License 2.0 4 votes vote down vote up
public static RemoteCall<Greeter> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, String _greeting) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.Utf8String(_greeting)));
    return deployRemoteCall(Greeter.class, web3j, credentials, contractGasProvider, BINARY, encodedConstructor);
}
 
Example 16
Source File: Greeter.java    From web3j with Apache License 2.0 4 votes vote down vote up
public static RemoteCall<Greeter> deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider, String _greeting) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.Utf8String(_greeting)));
    return deployRemoteCall(Greeter.class, web3j, transactionManager, contractGasProvider, BINARY, encodedConstructor);
}
 
Example 17
Source File: Ballot.java    From web3j with Apache License 2.0 4 votes vote down vote up
public static RemoteCall<Ballot> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, List<byte[]> proposalNames) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.DynamicArray<org.web3j.abi.datatypes.generated.Bytes32>(
                    org.web3j.abi.datatypes.generated.Bytes32.class,
                    org.web3j.abi.Utils.typeMap(proposalNames, org.web3j.abi.datatypes.generated.Bytes32.class))));
    return deployRemoteCall(Ballot.class, web3j, credentials, contractGasProvider, BINARY, encodedConstructor);
}
 
Example 18
Source File: Greeter.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
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);
}
 
Example 19
Source File: Greeter.java    From etherscan-explorer with GNU General Public License v3.0 4 votes vote down vote up
public static RemoteCall<Greeter> deploy(Web3j web3j, TransactionManager transactionManager, 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, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor);
}
 
Example 20
Source File: Ballot.java    From web3j with Apache License 2.0 4 votes vote down vote up
public static RemoteCall<Ballot> deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider, List<byte[]> proposalNames) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.DynamicArray<org.web3j.abi.datatypes.generated.Bytes32>(
                    org.web3j.abi.datatypes.generated.Bytes32.class,
                    org.web3j.abi.Utils.typeMap(proposalNames, org.web3j.abi.datatypes.generated.Bytes32.class))));
    return deployRemoteCall(Ballot.class, web3j, transactionManager, contractGasProvider, BINARY, encodedConstructor);
}