public LeaderboardDeploymentBase() : base(BYTECODE) { }
}
string privateKey = “PRIVATE_KEY_HERE”;
[Parameter(“string”, “user”, 1)]
public virtual BigInteger Score { get; set; }
[FunctionOutput]
public LeaderboardDeploymentBase(string byteCode) : base(byteCode) { }
public virtual string User { get; set; }
public LeaderboardDeployment() : base(BYTECODE) { }
{
// using Nethereum RPC
留意:在下面的代码中添加您的私钥。
};
}
· 下载的VS Code和Solidity插件
留意AddScoreFunction用于更新排行榜。它接管两个参数
{
public static string BYTECODE = “6080604052600a60015534801561001557600080fd5b50600080546001600160a01b03191633179055610641806100376000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063bf3683991461003b578063f4c5cd3c146100d7575b600080fd5b6100586004803603602081101561005157600080fd5b5035610193565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b8381101561009b578181015183820152602001610083565b50505050905090810190601f1680156100c85780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b61017f600480360360408110156100ed57600080fd5b81019060208101813564010000000081111561010857600080fd5b82018360208201111561011a57600080fd5b8035906020019184600183028401116401000000008311171561013c57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610234915050565b604080519115158252519081900360200190f35b600260208181526000928352604092839020805484516001821615610100026000190190911693909304601f81018390048302840183019094528383529283918301828280156102245780601f106101f957610100808354040283529160200191610224565b820191906000526020600020905b81548152906001019060200180831161020757829003601f168201915b5050505050908060010154905082565b600080546001600160a01b0316331461028c576040805162461bcd60e51b815260206004820152601560248201527414d95b99195c881b9bdd08185d5d1a1bdc9a5e9959605a1b604482015290519081900360640190fd5b60018054600019016000908152600260205260409020015482116102b257506000610511565b60005b60015481101561050f57600081815260026020526040902060010154831115610507576102e0610517565b600082815260026020818152604092839020835181546060601f600019610100600185161502019092169590950490810184900490930281018401855293840182815290928492849184018282801561037a5780601f1061034f5761010080835404028352916020019161037a565b820191906000526020600020905b81548152906001019060200180831161035d57829003601f168201915b505050918352505060019182015460209091015290915082015b600154600101811015610496576103a9610517565b600082815260026020818152604092839020835181546060601f60001961010060018516150201909216959095049081018490049093028101840185529384018281529092849284918401828280156104435780601f1061041857610100808354040283529160200191610443565b820191906000526020600020905b81548152906001019060200180831161042657829003601f168201915b50505091835250506001919091015460209182015260008481526002825260409020855180519394508693919261047f92849290910190610531565b506020919091015160019182015590925001610394565b5060408051808201825286815260208082018790526000858152600282529290922081518051929391926104cd9284920190610531565b50602091820151600191820155546000908152600290915260408120906104f482826105af565b5060006001918201559250610511915050565b6001016102b5565b505b92915050565b604051806040016040528060608152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061057257805160ff191683800117855561059f565b8280016001018555821561059f579182015b8281111561059f578251825591602001919060010190610584565b506105ab9291506105f6565b5090565b50805460018160011615610100020316600290046000825580601f106105d557506105f3565b601f0160209004906000526020600020908101906105f391906105f6565b50565b5b808211156105ab57600081556001016105f756fea2646970667358221220bfd3f013a19a6edc4d9068093362a43225391c67382b6869458b7a765b7dc09864736f6c63430007000033”;
该文件应复制到Unity项目。
}
复制生意业务ID并查抄区块欣赏器。
[Function(“leaderboard”, typeof(LeaderboardOutputDTO))]
}
Score = 4,
using Nethereum.ABI.FunctionEncoding.Attributes;
public partial class LeaderboardDeployment : LeaderboardDeploymentBase 从以太坊合约更新数据 // LeaderboardDefinition.cs 它应该在 打开UpdateLeaderboard.cs并更新剧本。
using Nethereum.Web3;
· 导入的Nethereum库
[Function(“addScore”, “bool”)]
[Parameter(“uint256”, “”, 1)]
[Parameter(“string”, “user”, 1)]
· 陈设智能合约:带有合约地点的代码
yield return transactionTransferRequest.SignAndSendTransaction(transactionMessage, contractAddress);
using System.Numerics;
public virtual BigInteger Score { get; set; }
{
先决条件
有关更多信息:https://github.com/Nethereum/Unity3dSimpleSample#transfer-transaction
{
public class LeaderboardFunctionBase : FunctionMessage
using System.Threading.Tasks;
using Nethereum.JsonRpc.UnityClient;
void Start()
}
打开您的Unity项目,并确保已添加Nethereum .dll文件。假如尚未完成,请查抄第1部门。
using System;
}
FromAddress = fromAddress,
{
本文将先容如何从Unity内部的智能合约中更新/变动数据。
给Unity添加C#界说
string contractAddress = “0xfeF8684259C1CBf3F436A57D83A5EB78b0D0bfcC”;
建设C#界说
using System.Collections.Generic;
User = “gavin”,
}
}
public class LeaderboardOutputDTOBase : IFunctionOutputDTO
public IEnumerator UpdateScore()
var transactionMessage = new AddScoreFunction
概述
using Nethereum.Contracts;
public partial class LeaderboardFunction : LeaderboardFunctionBase { }
using Nethereum.RPC.Eth.DTOs;
string fromAddress = “0x06C403f435d63835D027F517C2a231a663a1cF5E”;
出于演示目标,,请在Main Camera中建设剧本
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。