1

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
    }

}

3
  • 1
    MWM (last parameter of SendTransfer) should be 14?
    – mihi
    Dec 19, 2018 at 23:10
  • I changed it to 14, although it should be 14 it doesn't seem to be whats causing the error Dec 21, 2018 at 22:53
  • Can you try removing the Finalize and Sign 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.
    – mihi
    Dec 22, 2018 at 14:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.