I'm trying to integrate IOTA into the Unity game engine although whenever I try running the code I get "Insufficient value submitted" I have made sure that my seed is accurate and that I have enough money in my account. I tested the code with ONLY data transfers and it appears to work however value transactions don't
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Threading;
using RestSharp;
using Tangle.Net.Entity;
using Tangle.Net.ProofOfWork;
using Tangle.Net.Repository;
using Tangle.Net.Repository.Client;
using Tangle.Net.Repository.Factory;
using Tangle.Net.Utils;
using Tangle.Net.Cryptography;
public class PayUsers : MonoBehaviour
{
string accountSeed = "";
string nodeUri = "https://nodes.thetangle.org:443/";
public string sendAddress = "";
string message = "Thank you for playing IOTA clicker! Please consider supporting the game by donating or rating the game :)";
int sendAmount = 1;
public Button submit;
void Start()
{
Button btn = submit.GetComponent<Button>();
btn.onClick.AddListener(TaskOnClick);
}
void Update()
{
}
public void TaskOnClick()
{
if (true)
{
SendMessageWITOA(accountSeed, nodeUri, sendAddress, sendAmount, message);
}
}
void SendMessage(string nodeUri, string sendAddress, string message)
{
RestIotaClient iotaClient = new RestIotaClient(new RestClient(nodeUri));
PoWService powService = new PoWService(new CpuPearlDiver()); // the examples will use the CPU to do PoW for a transaction.
RestIotaRepository repository = new RestIotaRepository(iotaClient, powService);
Bundle bundle = new Bundle();
bundle.AddTransfer(new Transfer
{
Address = new Address(sendAddress),
Message = TryteString.FromUtf8String(message),
Tag = Tag.Empty,
Timestamp = Timestamp.UnixSecondsTimestamp
});
bundle.Finalize();
bundle.Sign();
repository.SendTrytes(bundle.Transactions, 2, 14);
}
public void SendMessageWITOA(string accountSeed, string nodeUri, string sendAddress, int sendAmount, string message)
{
RestIotaClient iotaClient = new RestIotaClient(new RestClient(nodeUri));
PoWService powService = new PoWService(new CpuPearlDiver()); // the examples will use the CPU to do PoW for a transaction.
RestIotaRepository repository = new RestIotaRepository(iotaClient, powService);
Seed sendSeed = new Seed(accountSeed);
Bundle bundle = new Bundle();
bundle.AddTransfer(
new Transfer
{
Address = new Address(sendAddress),
Tag = Tag.Empty,
//ValueToTransfer = 0000000000000010,
ValueToTransfer = sendAmount,
Timestamp = Timestamp.UnixSecondsTimestamp
});
bundle.Finalize();
bundle.Sign();
repository.SendTransfer(sendSeed, bundle, SecurityLevel.Medium, 4, 4); // 4 for money // 2 for no money
}
}
SendTransfer
) should be 14?Finalize
andSign
calls?SendTransfer
is supposed to sign the bundle with your seed (your address' private key), and I don't know if it minds if it is already signed... Also, if you have a stacktrace for that error, it might help to add it to your post.