Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfranblanco committed Dec 13, 2017
0 parents commit a11d219
Show file tree
Hide file tree
Showing 73 changed files with 2,727 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Library/
.git
.vs

64 changes: 64 additions & 0 deletions Assets/DecodeData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Nethereum.ABI.FunctionEncoding.Attributes;
using UnityEngine;
using Nethereum.Contracts;
using Nethereum.JsonRpc.UnityClient;

public class DecodeData : MonoBehaviour {

[FunctionOutput]
public class GetDataDTO
{
[Parameter("uint64", "birthTime", 1)]
public ulong BirthTime { get; set; }

[Parameter("string", "userName", 2)]
public string UserName { get; set; }

[Parameter("uint16", "starterId", 3)]
public int StarterId { get; set; }

[Parameter("uint16", "currLocation", 4)]
public int CurrLocation { get; set; }

[Parameter("bool", "isBusy", 5)]
public bool IsBusy { get; set; }

[Parameter("address", "owner", 6)]
public string Owner { get; set; }

}

void Start ()
{
StartCoroutine(GetData());
}

public IEnumerator GetData()
{
var contractAddress = "0x786a30e1ab0c58303c85419b9077657ad4fdb0ea";
var url = "http://localhost:8545";
var getDataCallUnityRequest = new EthCallUnityRequest(url);
var contract = new Contract(null, @"[{ 'constant':false,'inputs':[],'name':'getData','outputs':[{'name':'birthTime','type':'uint64'},{'name':'userName','type':'string'},{'name':'starterId','type':'uint16'},{'name':'currLocation','type':'uint16'},{'name':'isBusy','type':'bool'},{'name':'owner','type':'address'}],'payable':false,'stateMutability':'nonpayable','type':'function'}]", contractAddress);
var function = contract.GetFunction("getData");
var callInput = function.CreateCallInput();

yield return getDataCallUnityRequest.SendRequest(callInput, Nethereum.RPC.Eth.DTOs.BlockParameter.CreateLatest());
var result = getDataCallUnityRequest.Result;
var thing = new GetDataDTO();
var output = function.DecodeDTOTypeOutput<GetDataDTO>(thing, result);
Debug.Log("birth block " + output.BirthTime);
Debug.Log("curr location " + output.CurrLocation);
Debug.Log("busy" + output.IsBusy);
Debug.Log("starterid " + output.StarterId);
Debug.Log("userName " + output.UserName);
Debug.Log("ownerAddress " + output.Owner);
}

// Update is called once per frame
void Update () {

}
}
12 changes: 12 additions & 0 deletions Assets/DecodeData.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/Plugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/BouncyCastle.Crypto.dll
Binary file not shown.
34 changes: 34 additions & 0 deletions Assets/Plugins/BouncyCastle.Crypto.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Nethereum.ABI.dll
Binary file not shown.
34 changes: 34 additions & 0 deletions Assets/Plugins/Nethereum.ABI.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Nethereum.Contracts.dll
Binary file not shown.
34 changes: 34 additions & 0 deletions Assets/Plugins/Nethereum.Contracts.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Nethereum.Hex.dll
Binary file not shown.
34 changes: 34 additions & 0 deletions Assets/Plugins/Nethereum.Hex.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Nethereum.JsonRpc.Client.dll
Binary file not shown.
34 changes: 34 additions & 0 deletions Assets/Plugins/Nethereum.JsonRpc.Client.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Nethereum.KeyStore.dll
Binary file not shown.
34 changes: 34 additions & 0 deletions Assets/Plugins/Nethereum.KeyStore.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Nethereum.RLP.dll
Binary file not shown.
34 changes: 34 additions & 0 deletions Assets/Plugins/Nethereum.RLP.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Nethereum.RPC.dll
Binary file not shown.
34 changes: 34 additions & 0 deletions Assets/Plugins/Nethereum.RPC.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Nethereum.Signer.dll
Binary file not shown.
Loading

0 comments on commit a11d219

Please sign in to comment.