org.fisco.bcos.web3j.abi.datatypes.generated.Uint256 Java Examples

The following examples show how to use org.fisco.bcos.web3j.abi.datatypes.generated.Uint256. 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: EventEncoderTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature9() {
    Event event =
            new Event(
                    "test9",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Uint256>() {},
                            new TypeReference<StaticArray6<Uint256>>() {},
                            new TypeReference<DynamicArray<Uint256>>() {},
                            new TypeReference<Bool>() {},
                            new TypeReference<Address>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("test9(string,uint256,uint256[6],uint256[],bool,address)"));

    assertThat(
            EventEncoder.encode(event),
            is("0xa37d8a63087cf5837e0b9ff13d07d756479f8afdfe4b05ea3dfdc98154ef58ed"));

    assertThat(
            EventEncoder.buildEventSignature(
                    "test9(string,uint256,uint256[6],uint256[],bool,address)"),
            is("0xa37d8a63087cf5837e0b9ff13d07d756479f8afdfe4b05ea3dfdc98154ef58ed"));
}
 
Example #2
Source File: FunctionEncoderTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testEncodeInt() {
    assertThat(
            FunctionEncoder.encodeParameters(Arrays.asList(new Int256(0)), new StringBuilder()),
            is("0000000000000000000000000000000000000000000000000000000000000000"));
    assertThat(
            FunctionEncoder.encodeParameters(
                    Arrays.asList(new Int256(1111)), new StringBuilder()),
            is("0000000000000000000000000000000000000000000000000000000000000457"));
    assertThat(
            FunctionEncoder.encodeParameters(
                    Arrays.asList(new Int256(new BigInteger("-1"))), new StringBuilder()),
            is("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
    assertThat(
            FunctionEncoder.encodeParameters(
                    Arrays.asList(new Uint256(Long.MAX_VALUE)), new StringBuilder()),
            is("0000000000000000000000000000000000000000000000007fffffffffffffff"));
}
 
Example #3
Source File: ResultEntityTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void typeToObjectTest0() {

    assertThat(ResultEntity.typeToObject(new Uint256(2)), is(new BigInteger("2")));
    assertThat(ResultEntity.typeToObject(new Int256(-1)), is(new BigInteger("-1")));
    assertThat(ResultEntity.typeToObject(new Utf8String("adsfjkl")), is("adsfjkl"));
    assertThat(ResultEntity.typeToObject(new Bool(true)), is(true));
    assertThat(ResultEntity.typeToObject(new DynamicBytes("0x111".getBytes())), is("0x111"));
    assertThat(
            ResultEntity.typeToObject(new Address("0x111")),
            is("0x0000000000000000000000000000000000000111"));
    assertThat(
            ResultEntity.typeToObject(
                    new Bytes32("01234567890123456789012345678912".getBytes())),
            is("01234567890123456789012345678912"));
}
 
Example #4
Source File: TopicController.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple3<BigInteger, BigInteger, List<String>>> listTopicName(BigInteger pageIndex, BigInteger pageSize) {
    final Function function = new Function(FUNC_LISTTOPICNAME, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(pageIndex), 
            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(pageSize)), 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<DynamicArray<Utf8String>>() {}));
    return new RemoteCall<Tuple3<BigInteger, BigInteger, List<String>>>(
            new Callable<Tuple3<BigInteger, BigInteger, List<String>>>() {
                @Override
                public Tuple3<BigInteger, BigInteger, List<String>> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple3<BigInteger, BigInteger, List<String>>(
                            (BigInteger) results.get(0).getValue(), 
                            (BigInteger) results.get(1).getValue(), 
                            convertToNative((List<Utf8String>) results.get(2).getValue()));
                }
            });
}
 
Example #5
Source File: EventEncoderTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature8() {
    Event event =
            new Event(
                    "test8",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Address>() {},
                            new TypeReference<Uint256>() {},
                            new TypeReference<Int256>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("test8(string,address,uint256,int256)"));

    assertThat(
            EventEncoder.encode(event),
            is("0xfa3d7a982eb00eec003de55d3e9266fa4b9ccd6a3a067b75b24ef6b4cb9b12c4"));
    assertThat(
            EventEncoder.buildEventSignature("test8(string,address,uint256,int256)"),
            is("0xfa3d7a982eb00eec003de55d3e9266fa4b9ccd6a3a067b75b24ef6b4cb9b12c4"));
}
 
Example #6
Source File: Topic.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public void flushSnapshot(List<String> topicName, List<BigInteger> lastSequence, List<BigInteger> lastBlock,
                          List<BigInteger> lastTimestamp, List<String> lastSender, TransactionSucCallback callback) {
    final Function function = new Function(
            FUNC_FLUSHSNAPSHOT, 
            Arrays.<Type>asList(topicName.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("string[]"):
                    new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Utf8String>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(topicName, org.fisco.bcos.web3j.abi.datatypes.Utf8String.class)), 
            lastSequence.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSequence, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastBlock.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastBlock, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastTimestamp.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("uint256[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.generated.Uint256>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastTimestamp, org.fisco.bcos.web3j.abi.datatypes.generated.Uint256.class)), 
            lastSender.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"):
                new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(lastSender, org.fisco.bcos.web3j.abi.datatypes.Address.class))), 
            Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #7
Source File: EventEncoderTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature2() {
    Event event =
            new Event(
                    "f",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<DynamicBytes>() {},
                            new TypeReference<Bool>() {},
                            new TypeReference<DynamicArray<Uint256>>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("f(bytes,bool,uint256[])"));

    assertThat(
            EventEncoder.encode(event),
            is("0xa83b3f0112fa8ecc02937d734929bbaa30731fe27b20195418852fb64ac2837d"));

    assertThat(
            EventEncoder.buildEventSignature("f(bytes,bool,uint256[])"),
            is("0xa83b3f0112fa8ecc02937d734929bbaa30731fe27b20195418852fb64ac2837d"));
}
 
Example #8
Source File: Topic.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public Tuple5<List<String>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<String>> getFlushSnapshotInput(TransactionReceipt transactionReceipt) {
    String data = transactionReceipt.getInput().substring(10);
    final Function function = new Function(FUNC_FLUSHSNAPSHOT, 
            Arrays.<Type>asList(), 
            Arrays.<TypeReference<?>>asList(
                new TypeReference<DynamicArray<Utf8String>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Uint256>>() {},
                new TypeReference<DynamicArray<Address>>() {}));
    List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());;
    return new Tuple5<List<String>, List<BigInteger>, List<BigInteger>, List<BigInteger>, List<String>>(

            convertToNative((List<Utf8String>) results.get(0).getValue()), 
            convertToNative((List<Uint256>) results.get(1).getValue()), 
            convertToNative((List<Uint256>) results.get(2).getValue()), 
            convertToNative((List<Uint256>) results.get(3).getValue()), 
            convertToNative((List<Address>) results.get(4).getValue())
            );
}
 
Example #9
Source File: Topic.java    From WeEvent with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple4<BigInteger, BigInteger, BigInteger, String>> getSnapshot(String topicName) {
    final Function function = new Function(FUNC_GETSNAPSHOT, 
            Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(topicName)), 
            Arrays.<TypeReference<?>>asList(
                new TypeReference<Uint256>() {},
                new TypeReference<Uint256>() {},
                new TypeReference<Uint256>() {},
                new TypeReference<Address>() {}));
    return new RemoteCall<Tuple4<BigInteger, BigInteger, BigInteger, String>>(
            new Callable<Tuple4<BigInteger, BigInteger, BigInteger, String>>() {
                @Override
                public Tuple4<BigInteger, BigInteger, BigInteger, String> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple4<BigInteger, BigInteger, BigInteger, String>(
                            (BigInteger) results.get(0).getValue(), 
                            (BigInteger) results.get(1).getValue(), 
                            (BigInteger) results.get(2).getValue(), 
                            (String) results.get(3).getValue());
                }
            });
}
 
Example #10
Source File: DagTransfer.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple2<BigInteger, BigInteger>> userBalance(String user) {
    final Function function =
            new Function(
                    FUNC_USERBALANCE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user)),
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}));
    return new RemoteCall<Tuple2<BigInteger, BigInteger>>(
            new Callable<Tuple2<BigInteger, BigInteger>>() {
                @Override
                public Tuple2<BigInteger, BigInteger> call() throws Exception {
                    List<Type> results = executeCallMultipleValueReturn(function);
                    return new Tuple2<BigInteger, BigInteger>(
                            (BigInteger) results.get(0).getValue(),
                            (BigInteger) results.get(1).getValue());
                }
            });
}
 
Example #11
Source File: FunctionEncoderTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testMixTypeEncode4() {

    // function  set0(string,address,uint256,int256)
    Function function =
            new Function(
                    "set0",
                    Arrays.asList(
                            new Utf8String("aaafadsfsfadsfdasf"),
                            new Address("0x35ef07393b57464e93deb59175ff72e6499450cf"),
                            new Uint256(11111),
                            new Int256(-11111)),
                    Collections.singletonList(
                            new TypeReference<DynamicArray<Utf8String>>() {}));

    assertThat(
            FunctionEncoder.encodeParameters(
                    function.getInputParameters(), new StringBuilder()),
            is(
                    "00000000000000000000000000000000000000000000000000000000000000800000000"
                            + "0000000000000000035ef07393b57464e93deb59175ff72e6499450cf000000000000000000000000"
                            + "0000000000000000000000000000000000002b67fffffffffffffffffffffffffffffffffffffffff"
                            + "fffffffffffffffffffd4990000000000000000000000000000000000000000000000000000000000"
                            + "0000126161616661647366736661647366646173660000000000000000000000000000"));
}
 
Example #12
Source File: EventEncoderTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature6() {
    Event event =
            new Event(
                    "test6",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<Uint256>() {},
                            new TypeReference<Int256>() {},
                            new TypeReference<Utf8String>() {},
                            new TypeReference<DynamicArray<Utf8String>>() {},
                            new TypeReference<StaticArray3<Utf8String>>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("test6(uint256,int256,string,string[],string[3])"));

    assertThat(
            EventEncoder.encode(event),
            is("0x5199068657caa55d23ad866ba738a7f21e567e6f50aa8173ac108efdd5d3bb79"));

    assertThat(
            EventEncoder.buildEventSignature("test6(uint256,int256,string,string[],string[3])"),
            is("0x5199068657caa55d23ad866ba738a7f21e567e6f50aa8173ac108efdd5d3bb79"));
}
 
Example #13
Source File: EventEncoderTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testEventbuildMethodSignature0() {
    Event event =
            new Event(
                    "g",
                    Arrays.<TypeReference<?>>asList(
                            new TypeReference<DynamicArray<DynamicArray<Uint256>>>() {},
                            new TypeReference<DynamicArray<Utf8String>>() {}));

    assertThat(
            EventEncoder.buildMethodSignature(event.getName(), event.getParameters()),
            is("g(uint256[][],string[])"));

    assertThat(
            EventEncoder.encode(event),
            is("0x2289b18cd8c6e198648b35d3bcf2ff8668984543f01927711c161bcf7b5e1bba"));

    assertThat(
            EventEncoder.buildEventSignature("g(uint256[][],string[])"),
            is("0x2289b18cd8c6e198648b35d3bcf2ff8668984543f01927711c161bcf7b5e1bba"));
}
 
Example #14
Source File: FunctionReturnDecoderTest.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testDecodeStaticArrayValue() {
    List<TypeReference<Type>> outputParameters = new ArrayList<>(1);
    outputParameters.add((TypeReference) new TypeReference<StaticArray2<Uint256>>() {});
    outputParameters.add((TypeReference) new TypeReference<Uint256>() {});

    List<Type> decoded =
            FunctionReturnDecoder.decode(
                    "0x0000000000000000000000000000000000000000000000000000000000000037"
                            + "0000000000000000000000000000000000000000000000000000000000000001"
                            + "000000000000000000000000000000000000000000000000000000000000000a",
                    outputParameters);

    List<Type> expected =
            Arrays.asList(
                    new StaticArray2<Uint256>(
                            new Uint256(BigInteger.valueOf(55)), new Uint256(BigInteger.ONE)),
                    new Uint256(BigInteger.TEN));
    assertThat(decoded, equalTo(expected));
}
 
Example #15
Source File: ParallelOk.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String transferSeq(String from, String to, BigInteger num) {
    final Function function =
            new Function(
                    FUNC_TRANSFER,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(from),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(to),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(num)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #16
Source File: ParallelOk.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void transfer(String from, String to, BigInteger num, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_TRANSFER,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(from),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(to),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(num)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #17
Source File: FunctionReturnDecoderTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testMixTypeDecode4() {

    // function function(string,address,uint256,int256) constant
    // returns(string,address,uint256,int256)
    Function function =
            new Function(
                    "function",
                    Collections.<Type>emptyList(),
                    Arrays.asList(
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Address>() {},
                            new TypeReference<Uint256>() {},
                            new TypeReference<Int256>() {}));

    assertThat(
            FunctionReturnDecoder.decode(
                    "00000000000000000000000000000000000000000000000000000000000000800000000"
                            + "0000000000000000035ef07393b57464e93deb59175ff72e6499450cf000000000000000000000000"
                            + "0000000000000000000000000000000000002b67fffffffffffffffffffffffffffffffffffffffff"
                            + "fffffffffffffffffffd4990000000000000000000000000000000000000000000000000000000000"
                            + "0000126161616661647366736661647366646173660000000000000000000000000000",
                    function.getOutputParameters()),
            equalTo(
                    Arrays.asList(
                            new Utf8String("aaafadsfsfadsfdasf"),
                            new Address("0x35ef07393b57464e93deb59175ff72e6499450cf"),
                            new Uint256(11111),
                            new Int256(-11111))));
}
 
Example #18
Source File: ParallelOk.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String setSeq(String name, BigInteger num) {
    final Function function =
            new Function(
                    FUNC_SET,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(num)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #19
Source File: DagTransfer.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String userSaveSeq(String user, BigInteger balance) {
    final Function function =
            new Function(
                    FUNC_USERSAVE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(balance)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #20
Source File: DagTransfer.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void userSave(String user, BigInteger balance, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_USERSAVE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(balance)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}
 
Example #21
Source File: DagTransfer.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> userSave(String user, BigInteger balance) {
    final Function function =
            new Function(
                    FUNC_USERSAVE,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(balance)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #22
Source File: DagTransfer.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String userAddSeq(String user, BigInteger balance) {
    final Function function =
            new Function(
                    FUNC_USERADD,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(balance)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #23
Source File: FunctionReturnDecoderTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testMixTypeDecode2() {
    // function function() constant
    // returns(string,bool,uint256[])
    Function function =
            new Function(
                    "function",
                    Collections.<Type>emptyList(),
                    Arrays.asList(
                            new TypeReference<Utf8String>() {},
                            new TypeReference<Bool>() {},
                            new TypeReference<DynamicArray<Uint256>>() {}));

    assertThat(
            FunctionReturnDecoder.decode(
                    "0000000000000000000000000000000000000000000000000000000000000060"
                            + "0000000000000000000000000000000000000000000000000000000000000001"
                            + "00000000000000000000000000000000000000000000000000000000000000a0"
                            + "0000000000000000000000000000000000000000000000000000000000000004"
                            + "6461766500000000000000000000000000000000000000000000000000000000"
                            + "0000000000000000000000000000000000000000000000000000000000000003"
                            + "0000000000000000000000000000000000000000000000000000000000000001"
                            + "0000000000000000000000000000000000000000000000000000000000000002"
                            + "0000000000000000000000000000000000000000000000000000000000000003",
                    function.getOutputParameters()),
            equalTo(
                    Arrays.asList(
                            new Utf8String("dave"),
                            new Bool(true),
                            new DynamicArray<>(
                                    new Uint256(1), new Uint256(2), new Uint256(3)))));
}
 
Example #24
Source File: FunctionReturnDecoderTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testDecodeIndexedUint256Value() {
    Uint256 value = new Uint256(BigInteger.TEN);
    String encoded = TypeEncoder.encodeNumeric(value);

    assertThat(
            FunctionReturnDecoder.decodeIndexedValue(encoded, new TypeReference<Uint256>() {}),
            equalTo(value));
}
 
Example #25
Source File: NewSolTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> transfer(String to, BigInteger tokens) {
    final Function function =
            new Function(
                    FUNC_TRANSFER,
                    Arrays.<Type>asList(new Address(to), new Uint256(tokens)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #26
Source File: DagTransfer.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public String userTransferSeq(String user_a, String user_b, BigInteger amount) {
    final Function function =
            new Function(
                    FUNC_USERTRANSFER,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user_a),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user_b),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(amount)),
                    Collections.<TypeReference<?>>emptyList());
    return createTransactionSeq(function);
}
 
Example #27
Source File: FunctionReturnDecoderTest.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testMixTypeDecode1() {
    // function function() constant
    // returns(uint256,uint256[],uint256,bytes10,string)
    Function function =
            new Function(
                    "function",
                    Collections.<Type>emptyList(),
                    Arrays.asList(
                            new TypeReference<Uint256>() {},
                            new TypeReference<DynamicArray<Uint256>>() {},
                            new TypeReference<Bytes10>() {},
                            new TypeReference<Utf8String>() {}));

    assertThat(
            FunctionReturnDecoder.decode(
                    "0000000000000000000000000000000000000000000000000000000000000123"
                            + "0000000000000000000000000000000000000000000000000000000000000080"
                            + "3132333435363738393000000000000000000000000000000000000000000000"
                            + "00000000000000000000000000000000000000000000000000000000000000e0"
                            + "0000000000000000000000000000000000000000000000000000000000000002"
                            + "0000000000000000000000000000000000000000000000000000000000000456"
                            + "0000000000000000000000000000000000000000000000000000000000000789"
                            + "000000000000000000000000000000000000000000000000000000000000000d"
                            + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000",
                    function.getOutputParameters()),
            equalTo(
                    Arrays.asList(
                            new Uint256(291),
                            new DynamicArray<Uint256>(new Uint256(1110), new Uint256(1929)),
                            new Bytes10("1234567890".getBytes()),
                            new Utf8String("Hello, world!"))));
}
 
Example #28
Source File: DagTransfer.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> userTransfer(
        String user_a, String user_b, BigInteger amount) {
    final Function function =
            new Function(
                    FUNC_USERTRANSFER,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user_a),
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user_b),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(amount)),
                    Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #29
Source File: Ok.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public RemoteCall<BigInteger> get() {
    final Function function =
            new Function(
                    FUNC_GET,
                    Arrays.<Type>asList(),
                    Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
    return executeRemoteCallSingleValueReturn(function, BigInteger.class);
}
 
Example #30
Source File: DagTransfer.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void userDraw(String user, BigInteger balance, TransactionSucCallback callback) {
    final Function function =
            new Function(
                    FUNC_USERDRAW,
                    Arrays.<Type>asList(
                            new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user),
                            new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(balance)),
                    Collections.<TypeReference<?>>emptyList());
    asyncExecuteTransaction(function, callback);
}