-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathe06_send_tokens.java
More file actions
36 lines (30 loc) · 1.67 KB
/
e06_send_tokens.java
File metadata and controls
36 lines (30 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
This example creates a transaction with a custom message/tag.
The amount of iota specified in the "AMOUNT" variable will be transferred to the given address.
*/
import org.iota.jota.IotaAPI;
import org.iota.jota.connection.Connection;
import org.iota.jota.connection.HttpConnector;
import org.iota.jota.dto.response.GetBalancesAndFormatResponse;
import org.iota.jota.model.Input;
import org.iota.jota.model.Transfer;
import org.iota.jota.utils.TrytesConverter;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
public class e06_send_tokens {
public static String TEST_SEED = "BESTSEEDTESTSEEDTESTSEEDTESTSEEDTESTSEEDTESTSEEDTESTSEEDTESTSEEDTESTSEEDTESTSEED9";
public static String RECIPIENT_ADDRESS = "RYQZZGLWXZISBBJTLFCXVBCQBQKZZ9QKIYVPABXOIPUR9LB9CVGEGQSC9RQSJCMTTFHXSNHPKZXABGVGYAETJYRDPC";
public static long AMOUNT = 1;
public static void main(String[] args) throws MalformedURLException {
Connection node = new HttpConnector("https", "nodes.devnet.iota.org", 443);
IotaAPI iotaAPI = new IotaAPI.Builder().addNode(node).build();
List<Input> inputList;
List<Transfer> transfers = new ArrayList<>();
GetBalancesAndFormatResponse response = iotaAPI.getInputs(TEST_SEED, 2, 0, 10, 100);
inputList = new ArrayList<>(response.getInputs());
transfers.add(new Transfer(RECIPIENT_ADDRESS, AMOUNT, TrytesConverter.asciiToTrytes("HERE IS YOUR " + AMOUNT + " IOTA!"), "JAVA9WORKSHOP"));
iotaAPI.sendTransfer(TEST_SEED, 2, 2, 9, transfers, inputList, null, true, false, null);
System.out.println("Transaction sent!\nhttps://devnet.thetangle.org/address/" + RECIPIENT_ADDRESS);
}
}