public RemoteCall<TransactionReceipt> setText(byte[] node, String key, String value) { final Function function = new Function( FUNC_SETTEXT, Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(node), new org.web3j.abi.datatypes.Utf8String(key), new org.web3j.abi.datatypes.Utf8String(value)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
static String encodeString(Utf8String string) { byte[] utfEncoded = string.getValue().getBytes(StandardCharsets.UTF_8); return encodeDynamicBytes(new DynamicBytes(utfEncoded)); }
@Test public void testToString() { assertThat(new Utf8String("").toString(), is("")); assertThat(new Utf8String("string").toString(), is("string")); } }
private void callGreet(Greeter contract) throws Exception { System.out.println("// Call greet()"); Utf8String message = contract .greet() .get(); System.out.println("Message returned by Contract.greet(): " + message.toString()); printBalanceAlice("after greet"); System.out.println(); }
static Utf8String decodeUtf8String(String input, int offset) { DynamicBytes dynamicBytesResult = decodeDynamicBytes(input, offset); byte[] bytes = dynamicBytesResult.getValue(); return new Utf8String(new String(bytes, StandardCharsets.UTF_8)); }
static String encodeString(Utf8String string) { byte[] utfEncoded = string.getValue().getBytes(StandardCharsets.UTF_8); return encodeDynamicBytes(new DynamicBytes(utfEncoded)); }
public RemoteCall<String> text(byte[] node, String key) { final Function function = new Function(FUNC_TEXT, Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(node), new org.web3j.abi.datatypes.Utf8String(key)), Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {})); return executeRemoteCallSingleValueReturn(function, String.class); }
public RemoteCall<TransactionReceipt> setName(byte[] node, String name) { final Function function = new Function( FUNC_SETNAME, Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(node), new org.web3j.abi.datatypes.Utf8String(name)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
public RemoteCall<TransactionReceipt> newGreeting(String _greeting) { final Function function = new Function( FUNC_NEWGREETING, Arrays.<Type>asList(new org.web3j.abi.datatypes.Utf8String(_greeting)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
@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); }
@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); }
@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); }
@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); }
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); }
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); }
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); }
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, Credentials credentials, 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, credentials, contractGasProvider, BINARY, encodedConstructor); }
@Test public void testEncodeConstructorString() { assertThat(FunctionEncoder.encodeConstructor( Collections.singletonList(new Utf8String("Greetings!"))), is("0000000000000000000000000000000000000000000000000000000000000020" + "000000000000000000000000000000000000000000000000000000000000000a" + "4772656574696e67732100000000000000000000000000000000000000000000")); }
@Test public void testUtf8String() { Utf8String string = new Utf8String("Hello, world!"); assertThat(TypeEncoder.encodeString(string), is("000000000000000000000000000000000000000000000000000000000000000d" + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000")); }
@Test public void testUtf8String() { assertThat(TypeDecoder.decodeUtf8String( "000000000000000000000000000000000000000000000000000000000000000d" // length + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000", 0), is(new Utf8String("Hello, world!"))); }