{"id":19903204,"url":"https://github.com/nethereum/unity3dsimplesample","last_synced_at":"2026-03-16T20:33:29.464Z","repository":{"id":89828964,"uuid":"114121550","full_name":"Nethereum/Unity3dSimpleSample","owner":"Nethereum","description":"Simple Unity3d sample","archived":false,"fork":false,"pushed_at":"2022-10-18T14:47:30.000Z","size":15216,"stargazers_count":48,"open_issues_count":7,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-28T08:48:48.371Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nethereum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-13T13:03:06.000Z","updated_at":"2024-02-03T20:44:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"bd770697-37a4-4490-8199-71b212ab28bb","html_url":"https://github.com/Nethereum/Unity3dSimpleSample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nethereum%2FUnity3dSimpleSample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nethereum%2FUnity3dSimpleSample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nethereum%2FUnity3dSimpleSample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nethereum%2FUnity3dSimpleSample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nethereum","download_url":"https://codeload.github.com/Nethereum/Unity3dSimpleSample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252126359,"owners_count":21698962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T20:22:29.517Z","updated_at":"2026-03-16T20:33:24.436Z","avatar_url":"https://github.com/Nethereum.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unity3d Simple Sample (Ether transfer, ERC20 Contract deployment, transfer, query and balance)\n\n# PLEASE GO TO https://github.com/Nethereum/Unity3dSampleTemplate FOR THE LATEST SAMPLE\n\nThis sample demonstrates how to transfer Ether and the interaction with as smart contract (in this scenario an ERC20 token smart contract) including Deployment of the contract, Transfer of a token (transaction), Query the balance of a token (calls) and finally retrieve Events from Ethereum.\n\nThis sample uses the latest version of Nethereum which you can download from the releases. \n\n**Note:**\n\nPlease remember to remove System.HttpCliend and UnityEngine of the Nethereum release package if included\n\nThe sample is outdated in some areas, if upgrading check the current small changes here \nhttps://github.com/Nethereum/Nethereum/blob/master/src/Nethereum.Unity/\nFor example:\nhttps://github.com/Nethereum/Nethereum/blob/master/src/Nethereum.Unity/EthTransferUnityRequest.cs#L11\n\n\n## Simple Ether transfer\nTo transfer Ether Nethereum provides a specific Unity Request, the ```EthTransferUnityRequest```.\n\nThe EthTransferUnityRequest it is instantiated with the \"url\" of our Ethereum client, the private key to be able to sign transactions and our account address (the same of the private key).\n\n```csharp\nvar url = \"http://localhost:8545\";\nvar privateKey = \"0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7\"; \nvar account = \"0x12890d2cce102216644c59daE5baed380d84830c\";\nvar ethTransfer = new EthTransferUnityRequest(url, privateKey, account);\n```\n\nOnce our unity request is instantiated it we can initiate the transfer as follows:\n\n```csharp\nvar receivingAddress = \"0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe\";\nyield return ethTransfer.TransferEther(receivingAddress, 1.1m, 2);\n```\n\nHere we have specified the receivingAddress, the amount to send and the optional gas price in Gwei. The request will automatically convert the gas price to Wei.\n\nWe can validate afterwards if we have had any exception as following:\n```\nif (ethTransfer.Exception != null)\n{\n    Debug.Log(ethTransfer.Exception.Message);\n    yield break;\n}\n```\n\nIf no errors have occurred we can retrieve the transaction hash from the Request and Poll every 2 seconds to wait for the transaction to be mined.\n\n```csharp\n var transactionHash = ethTransfer.Result;\n//create a poll to get the receipt when mined\nvar transactionReceiptPolling = new TransactionReceiptPollingRequest(url);\n//checking every 2 seconds for the receipt\nyield return transactionReceiptPolling.PollForReceipt(transactionHash, 2);\n```\n\nFinally we can check the balance of our recieving account, using ```EthGetBalanceUnityRequest```. Note that we specify we want the balance for the latest Block when doing the request.\n\n```csharp\nvar balanceRequest = new EthGetBalanceUnityRequest(url);\nyield return balanceRequest.SendRequest(receivingAddress, BlockParameter.CreateLatest());\n```\n\nWe can convert the result in Wei to Eth using the default Wei UnitConvertor.\n\n```csharp\nDebug.Log(\"Balance of account:\" + UnitConversion.Convert.FromWei(balanceRequest.Result.Value));\n```\n\n### Full sample\n```csharp\npublic IEnumerator TransferEther()\n    {\n        var url = \"http://localhost:8545\";\n        var privateKey = \"0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7\";\n        var account = \"0x12890d2cce102216644c59daE5baed380d84830c\";\n        //initialising the transaction request sender\n        var ethTransfer = new EthTransferUnityRequest(url, privateKey, account);\n        \n        var receivingAddress = \"0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe\";\n        yield return ethTransfer.TransferEther(\"0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe\", 1.1m, 2);\n\n        if (ethTransfer.Exception != null)\n        {\n            Debug.Log(ethTransfer.Exception.Message);\n            yield break;\n        }\n\n        var transactionHash = ethTransfer.Result;\n\n        Debug.Log(\"Transfer transaction hash:\" + transactionHash);\n\n        //create a poll to get the receipt when mined\n        var transactionReceiptPolling = new TransactionReceiptPollingRequest(url);\n        //checking every 2 seconds for the receipt\n        yield return transactionReceiptPolling.PollForReceipt(transactionHash, 2);\n        \n        Debug.Log(\"Transaction mined\");\n\n        var balanceRequest = new EthGetBalanceUnityRequest(url);\n        yield return balanceRequest.SendRequest(receivingAddress, BlockParameter.CreateLatest());\n        \n        \n        Debug.Log(\"Balance of account:\" + UnitConversion.Convert.FromWei(balanceRequest.Result.Value));\n    }\n\n```\n\n# Smart contract Integration\n\nThis sample covers all the steps of smart contract integration using the ERC20 standard token.\n\n## Declare our smart contract definition\nFirst step is to include our smart contract definition, this can be code generated using the vscode solidity extension or the console code generation tool.\n\n```csharp\n//Deployment contract object definition\n    public partial class EIP20Deployment : EIP20DeploymentBase\n    {\n        public EIP20Deployment() : base(BYTECODE) { }\n        public EIP20Deployment(string byteCode) : base(byteCode) { }\n    }\n\n\n\n    public class EIP20DeploymentBase : ContractDeploymentMessage\n    {\n        public static string BYTECODE = \"608060405234801561001057600080fd5b506040516107843803806107848339810160409081528151602080840151838501516060860151336000908152808552959095208490556002849055908501805193959094919391019161006991600391860190610096565b506004805460ff191660ff8416179055805161008c906005906020840190610096565b5050505050610131565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100d757805160ff1916838001178555610104565b82800160010185558215610104579182015b828111156101045782518255916020019190600101906100e9565b50610110929150610114565b5090565b61012e91905b80821115610110576000815560010161011a565b90565b610644806101406000396000f3006080604052600436106100ae5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100b3578063095ea7b31461013d57806318160ddd1461017557806323b872dd1461019c57806327e235e3146101c6578063313ce567146101e75780635c6581651461021257806370a082311461023957806395d89b411461025a578063a9059cbb1461026f578063dd62ed3e14610293575b600080fd5b3480156100bf57600080fd5b506100c86102ba565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101025781810151838201526020016100ea565b50505050905090810190601f16801561012f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561014957600080fd5b50610161600160a060020a0360043516602435610348565b604080519115158252519081900360200190f35b34801561018157600080fd5b5061018a6103ae565b60408051918252519081900360200190f35b3480156101a857600080fd5b50610161600160a060020a03600435811690602435166044356103b4565b3480156101d257600080fd5b5061018a600160a060020a03600435166104b7565b3480156101f357600080fd5b506101fc6104c9565b6040805160ff9092168252519081900360200190f35b34801561021e57600080fd5b5061018a600160a060020a03600435811690602435166104d2565b34801561024557600080fd5b5061018a600160a060020a03600435166104ef565b34801561026657600080fd5b506100c861050a565b34801561027b57600080fd5b50610161600160a060020a0360043516602435610565565b34801561029f57600080fd5b5061018a600160a060020a03600435811690602435166105ed565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103405780601f1061031557610100808354040283529160200191610340565b820191906000526020600020905b81548152906001019060200180831161032357829003601f168201915b505050505081565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025481565b600160a060020a03831660008181526001602090815260408083203384528252808320549383529082905281205490919083118015906103f45750828110155b15156103ff57600080fd5b600160a060020a038085166000908152602081905260408082208054870190559187168152208054849003905560001981101561046157600160a060020a03851660009081526001602090815260408083203384529091529020805484900390555b83600160a060020a031685600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3506001949350505050565b60006020819052908152604090205481565b60045460ff1681565b600160209081526000928352604080842090915290825290205481565b600160a060020a031660009081526020819052604090205490565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103405780601f1061031557610100808354040283529160200191610340565b3360009081526020819052604081205482111561058157600080fd5b3360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b600160a060020a039182166000908152600160209081526040808320939094168252919091522054905600a165627a7a7230582084c618322109054a21a57e27075384a6172ab854e4b2c2d35062a964a6bf593f0029\";\n\n        public EIP20DeploymentBase() : base(BYTECODE) { }\n\n        public EIP20DeploymentBase(string byteCode) : base(byteCode) { }\n\n        [Parameter(\"uint256\", \"_initialAmount\", 1)]\n\n        public BigInteger InitialAmount { get; set; }\n\n        [Parameter(\"string\", \"_tokenName\", 2)]\n\n        public string TokenName { get; set; }\n\n        [Parameter(\"uint8\", \"_decimalUnits\", 3)]\n\n        public byte DecimalUnits { get; set; }\n\n        [Parameter(\"string\", \"_tokenSymbol\", 4)]\n\n        public string TokenSymbol { get; set; }\n\n    }\n\n\n\n    [Function(\"transfer\", \"bool\")]\n    public class TransferFunctionBase : FunctionMessage\n    {\n        [Parameter(\"address\", \"_to\", 1)]\n        public string To { get; set; }\n        [Parameter(\"uint256\", \"_value\", 2)]\n        public BigInteger Value { get; set; }\n    }\n\n\n\n    public partial class TransferFunction : TransferFunctionBase\n    {\n    }\n\n    [Function(\"balanceOf\", \"uint256\")]\n    public class BalanceOfFunction : FunctionMessage\n    {\n        [Parameter(\"address\", \"_owner\", 1)]\n        public string Owner { get; set; }\n    }\n\n    [FunctionOutput]\n    public class BalanceOfFunctionOutput : IFunctionOutputDTO\n    {\n        [Parameter(\"uint256\", 1)]\n        public int Balance { get; set; }\n    }\n    \n    [Event(\"Transfer\")]\n    public class TransferEventDTOBase : IEventDTO\n    {\n        [Parameter(\"address\", \"_from\", 1, true)]\n        public virtual string From { get; set; }\n\n        [Parameter(\"address\", \"_to\", 2, true)]\n        public virtual string To { get; set; }\n\n        [Parameter(\"uint256\", \"_value\", 3, false)]\n        public virtual BigInteger Value { get; set; }\n    }\n\n    public partial class TransferEventDTO : TransferEventDTOBase\n    {\n        public static EventABI GetEventABI()\n        {\n            return EventExtensions.GetEventABI\u003cTransferEventDTO\u003e();\n        }\n    }\n```\n\n## Contract deployment\nTo deploy a smart contract we create a TransactionSignedUnityRequest with our url and signing information.\nCreating a new EIP20Deployment contract definition we set the constructor parameters and send the transaction.\nFinally we we create TransactionReceiptPollingRequest to poll for the transaction receipt and retrieve the newly deployed contract address from the transaction receipt.\n\n```csharp\n        var url = \"http://localhost:8545\";\n        var privateKey = \"0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7\";\n        var account = \"0x12890d2cce102216644c59daE5baed380d84830c\";\n        //initialising the transaction request sender\n        \n        var transactionRequest = new TransactionSignedUnityRequest(url, privateKey, account);\n\n        var deployContract = new EIP20Deployment()\n        {\n            InitialAmount = 10000,\n            FromAddress = account,\n            TokenName = \"TST\",\n            TokenSymbol = \"TST\"\n        };\n\n        //deploy the contract\n        yield return transactionRequest.SignAndSendDeploymentContractTransaction\u003cEIP20DeploymentBase\u003e(deployContract);\n\n        if (transactionRequest.Exception != null)\n        {\n            Debug.Log(transactionRequest.Exception.Message);\n            yield break;\n        }\n\n        var transactionHash = transactionRequest.Result;\n        Debug.Log(\"Deployment transaction hash:\" + transactionHash);\n\n        //create a poll to get the receipt when mined\n        var transactionReceiptPolling = new TransactionReceiptPollingRequest(url);\n\n        //checking every 2 seconds for the receipt\n        yield return transactionReceiptPolling.PollForReceipt(transactionHash, 2);\n\n        var deploymentReceipt = transactionReceiptPolling.Result;\n\n        Debug.Log(\"Deployment contract address:\" + deploymentReceipt.ContractAddress);\n```\n\n## Query smart contract\nTo Query a smart contract we need to create a new QueryUnityRequest providing the FunctionType and ReturnType.\nWe then will yield the Query and the query result Result object will provide us the Ouput of the contract already decoded.\n\n```csharp\n //Query request using our acccount and the contracts address (no parameters needed and default values)\n        var queryRequest = new QueryUnityRequest\u003cBalanceOfFunction, BalanceOfFunctionOutput\u003e(url, account);\n        yield return queryRequest.Query(new BalanceOfFunction(){Owner = account}, deploymentReceipt.ContractAddress);\n\n        //Getting the dto response already decoded\n        var dtoResult = queryRequest.Result;\n        Debug.Log(dtoResult.Balance);\n```\n\n## Transfer transaction\nTo send a transaction to interact with a smart contract has similar steps to the deployment.\nWe first create a TransactionSignedUnityRequest and our Function including any parameters, once the transaction is send we poll for the transaction receipt which will confirm the success of the transaction.\n\nUsing the transaction receipt we can decoded any logs / events for that transaction.\n\n```csharp\n var transactionTransferRequest = new TransactionSignedUnityRequest(url, privateKey, account);\n        var newAddress = \"0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe\";\n\n\n        var transactionMessage = new TransferFunction\n        {\n            FromAddress = account,\n            To = newAddress,\n            Value = 1000,\n        };\n\n        yield return transactionTransferRequest.SignAndSendTransaction(transactionMessage, deploymentReceipt.ContractAddress);\n        var transactionTransferHash = transactionTransferRequest.Result;\n\n        Debug.Log(\"Transfer txn hash:\" + transactionHash);\n\n        transactionReceiptPolling = new TransactionReceiptPollingRequest(url);\n        yield return transactionReceiptPolling.PollForReceipt(transactionTransferHash, 2);\n        var transferReceipt = transactionReceiptPolling.Result;\n\n        var transferEvent = transferReceipt.DecodeAllEvents\u003cTransferEventDTO\u003e();\n        Debug.Log(\"Transferd amount from event: \" + transferEvent[0].Event.Value);\n```\n\n## Logs and Events\nTo retrived the logs / events of a smart contract we use the EthGetLogsUnityRequest combined with a FilterInput specific to our Event.\nFilterInputs can be created using the EventDTO extension GetEventABI().\nOnce we have yield the request, we can decode all matching events using the Result.DecodeAllEvents\u003cTransferEventDTO\u003e, extension method.\n\n```csharp\n        var getLogsRequest = new EthGetLogsUnityRequest(url);\n        var eventTransfer = TransferEventDTO.GetEventABI();\n        yield return getLogsRequest.SendRequest(eventTransfer.CreateFilterInput(deploymentReceipt.ContractAddress, account));\n        var eventDecoded = getLogsRequest.Result.DecodeAllEvents\u003cTransferEventDTO\u003e();\n        Debug.Log(\"Transferd amount from get logs event: \" + eventDecoded[0].Event.Value);\n```\n\n## Full sample\n```csharp\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Numerics;\nusing Nethereum.ABI.FunctionEncoding.Attributes;\nusing Nethereum.ABI.Model;\nusing Nethereum.Contracts;\nusing Nethereum.Contracts.CQS;\nusing Nethereum.Contracts.Extensions;\nusing Nethereum.JsonRpc.UnityClient;\nusing UnityEngine;\n\n\npublic class TokenDeployAndSend : MonoBehaviour {\n\n\n\n    //Deployment contract object definition\n    public partial class EIP20Deployment : EIP20DeploymentBase\n    {\n        public EIP20Deployment() : base(BYTECODE) { }\n        public EIP20Deployment(string byteCode) : base(byteCode) { }\n    }\n\n\n\n    public class EIP20DeploymentBase : ContractDeploymentMessage\n    {\n        public static string BYTECODE = \"608060405234801561001057600080fd5b506040516107843803806107848339810160409081528151602080840151838501516060860151336000908152808552959095208490556002849055908501805193959094919391019161006991600391860190610096565b506004805460ff191660ff8416179055805161008c906005906020840190610096565b5050505050610131565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100d757805160ff1916838001178555610104565b82800160010185558215610104579182015b828111156101045782518255916020019190600101906100e9565b50610110929150610114565b5090565b61012e91905b80821115610110576000815560010161011a565b90565b610644806101406000396000f3006080604052600436106100ae5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100b3578063095ea7b31461013d57806318160ddd1461017557806323b872dd1461019c57806327e235e3146101c6578063313ce567146101e75780635c6581651461021257806370a082311461023957806395d89b411461025a578063a9059cbb1461026f578063dd62ed3e14610293575b600080fd5b3480156100bf57600080fd5b506100c86102ba565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101025781810151838201526020016100ea565b50505050905090810190601f16801561012f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561014957600080fd5b50610161600160a060020a0360043516602435610348565b604080519115158252519081900360200190f35b34801561018157600080fd5b5061018a6103ae565b60408051918252519081900360200190f35b3480156101a857600080fd5b50610161600160a060020a03600435811690602435166044356103b4565b3480156101d257600080fd5b5061018a600160a060020a03600435166104b7565b3480156101f357600080fd5b506101fc6104c9565b6040805160ff9092168252519081900360200190f35b34801561021e57600080fd5b5061018a600160a060020a03600435811690602435166104d2565b34801561024557600080fd5b5061018a600160a060020a03600435166104ef565b34801561026657600080fd5b506100c861050a565b34801561027b57600080fd5b50610161600160a060020a0360043516602435610565565b34801561029f57600080fd5b5061018a600160a060020a03600435811690602435166105ed565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103405780601f1061031557610100808354040283529160200191610340565b820191906000526020600020905b81548152906001019060200180831161032357829003601f168201915b505050505081565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025481565b600160a060020a03831660008181526001602090815260408083203384528252808320549383529082905281205490919083118015906103f45750828110155b15156103ff57600080fd5b600160a060020a038085166000908152602081905260408082208054870190559187168152208054849003905560001981101561046157600160a060020a03851660009081526001602090815260408083203384529091529020805484900390555b83600160a060020a031685600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3506001949350505050565b60006020819052908152604090205481565b60045460ff1681565b600160209081526000928352604080842090915290825290205481565b600160a060020a031660009081526020819052604090205490565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103405780601f1061031557610100808354040283529160200191610340565b3360009081526020819052604081205482111561058157600080fd5b3360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b600160a060020a039182166000908152600160209081526040808320939094168252919091522054905600a165627a7a7230582084c618322109054a21a57e27075384a6172ab854e4b2c2d35062a964a6bf593f0029\";\n\n        public EIP20DeploymentBase() : base(BYTECODE) { }\n\n        public EIP20DeploymentBase(string byteCode) : base(byteCode) { }\n\n        [Parameter(\"uint256\", \"_initialAmount\", 1)]\n\n        public BigInteger InitialAmount { get; set; }\n\n        [Parameter(\"string\", \"_tokenName\", 2)]\n\n        public string TokenName { get; set; }\n\n        [Parameter(\"uint8\", \"_decimalUnits\", 3)]\n\n        public byte DecimalUnits { get; set; }\n\n        [Parameter(\"string\", \"_tokenSymbol\", 4)]\n\n        public string TokenSymbol { get; set; }\n\n    }\n\n\n\n    [Function(\"transfer\", \"bool\")]\n    public class TransferFunctionBase : FunctionMessage\n    {\n        [Parameter(\"address\", \"_to\", 1)]\n        public string To { get; set; }\n        [Parameter(\"uint256\", \"_value\", 2)]\n        public BigInteger Value { get; set; }\n    }\n\n\n\n    public partial class TransferFunction : TransferFunctionBase\n    {\n    }\n\n    [Function(\"balanceOf\", \"uint256\")]\n    public class BalanceOfFunction : FunctionMessage\n    {\n        [Parameter(\"address\", \"_owner\", 1)]\n        public string Owner { get; set; }\n    }\n\n    [FunctionOutput]\n    public class BalanceOfFunctionOutput : IFunctionOutputDTO\n    {\n        [Parameter(\"uint256\", 1)]\n        public int Balance { get; set; }\n    }\n    \n    [Event(\"Transfer\")]\n    public class TransferEventDTOBase : IEventDTO\n    {\n        [Parameter(\"address\", \"_from\", 1, true)]\n        public virtual string From { get; set; }\n\n        [Parameter(\"address\", \"_to\", 2, true)]\n        public virtual string To { get; set; }\n\n        [Parameter(\"uint256\", \"_value\", 3, false)]\n        public virtual BigInteger Value { get; set; }\n    }\n\n    public partial class TransferEventDTO : TransferEventDTOBase\n    {\n        public static EventABI GetEventABI()\n        {\n            return EventExtensions.GetEventABI\u003cTransferEventDTO\u003e();\n        }\n    }\n\n\n\n    // Use this for initialization\n    void Start () {\n\n       // StartCoroutine(DeployAndTransferToken());\n    }\n\n\n    //Sample of new features / requests\n    public IEnumerator DeployAndTransferToken()\n    {\n\n        var url = \"http://localhost:8545\";\n        var privateKey = \"0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7\";\n        var account = \"0x12890d2cce102216644c59daE5baed380d84830c\";\n        //initialising the transaction request sender\n        \n        var transactionRequest = new TransactionSignedUnityRequest(url, privateKey, account);\n\n        var deployContract = new EIP20Deployment()\n        {\n            InitialAmount = 10000,\n            FromAddress = account,\n            TokenName = \"TST\",\n            TokenSymbol = \"TST\"\n        };\n\n        //deploy the contract\n        yield return transactionRequest.SignAndSendDeploymentContractTransaction\u003cEIP20DeploymentBase\u003e(deployContract);\n\n        if (transactionRequest.Exception != null)\n        {\n            Debug.Log(transactionRequest.Exception.Message);\n            yield break;\n        }\n\n        var transactionHash = transactionRequest.Result;\n        Debug.Log(\"Deployment transaction hash:\" + transactionHash);\n\n        //create a poll to get the receipt when mined\n        var transactionReceiptPolling = new TransactionReceiptPollingRequest(url);\n\n        //checking every 2 seconds for the receipt\n        yield return transactionReceiptPolling.PollForReceipt(transactionHash, 2);\n\n        var deploymentReceipt = transactionReceiptPolling.Result;\n\n        Debug.Log(\"Deployment contract address:\" + deploymentReceipt.ContractAddress);\n\n        //Query request using our acccount and the contracts address (no parameters needed and default values)\n        var queryRequest = new QueryUnityRequest\u003cBalanceOfFunction, BalanceOfFunctionOutput\u003e(url, account);\n        yield return queryRequest.Query(new BalanceOfFunction(){Owner = account}, deploymentReceipt.ContractAddress);\n\n        //Getting the dto response already decoded\n        var dtoResult = queryRequest.Result;\n        Debug.Log(dtoResult.Balance);\n\n        var transactionTransferRequest = new TransactionSignedUnityRequest(url, privateKey, account);\n        var newAddress = \"0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe\";\n\n\n        var transactionMessage = new TransferFunction\n        {\n            FromAddress = account,\n            To = newAddress,\n            Value = 1000,\n        };\n\n        yield return transactionTransferRequest.SignAndSendTransaction(transactionMessage, deploymentReceipt.ContractAddress);\n        var transactionTransferHash = transactionTransferRequest.Result;\n\n        Debug.Log(\"Transfer txn hash:\" + transactionHash);\n\n        transactionReceiptPolling = new TransactionReceiptPollingRequest(url);\n        yield return transactionReceiptPolling.PollForReceipt(transactionTransferHash, 2);\n        var transferReceipt = transactionReceiptPolling.Result;\n\n        var transferEvent = transferReceipt.DecodeAllEvents\u003cTransferEventDTO\u003e();\n        Debug.Log(\"Transferd amount from event: \" + transferEvent[0].Event.Value);\n\n        var getLogsRequest = new EthGetLogsUnityRequest(url);\n        var eventTransfer = TransferEventDTO.GetEventABI();\n        yield return getLogsRequest.SendRequest(eventTransfer.CreateFilterInput(deploymentReceipt.ContractAddress, account));\n\n        var eventDecoded = getLogsRequest.Result.DecodeAllEvents\u003cTransferEventDTO\u003e();\n        Debug.Log(\"Transferd amount from get logs event: \" + eventDecoded[0].Event.Value);\n\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnethereum%2Funity3dsimplesample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnethereum%2Funity3dsimplesample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnethereum%2Funity3dsimplesample/lists"}