如何开始使用 IOTA 应用程序

How to start with IOTA application

我想开发一个 IOTA 应用程序,但不是消息应用程序或基于硬币的系统。我想要一个如何在 IOTA 中存储数据的简单示例。例如,我想构建一个 SCM 甚至一个简单的 login/registration 应用程序。谁能指导我?任何示例应用程序?我试着 运行 https://github.com/domschiener/leaderboard-example But getting same error like https://github.com/domschiener/leaderboard-example/issues/6 如何 运行 这个。

在 tangle 上存储文本数据并不难。以下是我基于 tangle 的应用程序的片段。我使用了 IOTA 的 API Java 包装库 Jota.

1) 连接到 IOTA 节点。您可以在此处找到节点列表 https://nodes.iota.works。您也可以设置自己的完整节点并使用它来代替外部节点。

final String protocol = "https";
final String url = "tuna.iotasalad.org"; 
final String port = "14265";
IotaAPI iotaServer = new IotaAPI.Builder().protocol(protocol).host(host).port(port).build();

2) 将您的文本转换为 trytes

String trytes = TrytesConverter.toTrytes("my text");

3) 准备并发送交易到 tangle

private static final String SEED = "IHDEENZYITYVYSPKAURUZAQKGVJERUZDJMYTANNZZGPZ9GKWTEOJJ9AAMXOGZNQLSNMFDSQOTZAEETA99";//just a random one
private static final int MIN_WEIGHT_MAGNITUDE = 14;
private static final int DEPTH = 9;
private static final int TAG = "mytag"; //optional

String tangleHash = prepareTransfer(createAddress(), trytes);

public String createAddress() throws ArgumentException {
     GetNewAddressResponse res = iotaServer.getNewAddress(SEED, 2, 0, false, 1, false);
     return res.getAddresses().get(0);
}

public String prepareTransfer(String address_seclevel_2, String trytes) throws ArgumentException {
    List<Transfer> transfers = new ArrayList<Transfer>();
    transfers.add(new Transfer(address_seclevel_2, 0, trytes, TAG));
    SendTransferResponse str = iotaServer.sendTransfer(SEED, 2, DEPTH, MIN_WEIGHT_MAGNITUDE, transfers, null,
                    null, false, false);
    if(str.getSuccessfully()!=null){
        //Transfer successfully! 

        for(Transaction tx: str.getTransactions()) {
            return tx.getHash();
        }

    }
    return "Handle error here. Something went wrong!";

}