Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice


Discussion in 'Scripting' started by KrazyKewlB, Aug 17, 2019.

  1. KrazyKewlB


    Jul 25, 2019
    I've been trying to deal with a simple POST webrequest for 3 weeks and have now come to a standstill. I can successfully send a request to generate a new wallet address and privateKey but that endpoint takes no parameters. I use the same api{pk,to_address,asset_Id,amount} obviously containg thae values in hexString hexString 2 ints.The user must only input pk. So I tryed C#2json to no luck.
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.Networking;
    using System;
    using UnityEngine.UI;
    public class TransferAsset : MonoBehaviour{
    /*create,sign broadcast
    * curl -X POST -d '{"privateKey":"users", "to_address": "41e552f6487585c2b58bc2c9bb4492bc1f17132cd0", "asset_Id": "1002169", "amount": 10}'
    string owner_address;
    public InputField ownersAddress;
    // Start is called before the first frame update
    void Start()
    privateKey = GetComponent<InputField>().text;
    IEnumerator CreateTransaction()
    UnityWebRequest request = new UnityWebRequest("");
    string json;
    json = "{\"owner_address\":\"41d1e7a6bc354106cb410e65ff8b181c600ff14292\", \"to_address\": \"41e552f6487585c2b58bc2c9bb4492bc1f17132cd0\", \"asset_name\": \"31303030303031\", \"amount\": 100}";
    jsonToSend = JsonUtility.ToJson(json);
    byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(json);
    request.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend);
    request.SetRequestHeader("Content-Type", "application/json");
    request.downloadHandler = new DownloadHandlerBuffer();
    yield return request.SendWebRequest();
    if (request.isNetworkError){
    byte[] results =;
    if (request.isDone)
    Sign();//another ienum