Skip to content

Commit 53ae152

Browse files
committed
save
1 parent 77b71a7 commit 53ae152

26 files changed

+621
-14151
lines changed

Web3/Assets/EasyEthereum/Scenes/demo.unity

Lines changed: 63 additions & 4647 deletions
Large diffs are not rendered by default.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace EasyWeb3 {
2+
public class Constants {
3+
public static readonly bool debug = true;
4+
public static readonly string NODEDEFAULT_ETH_MAINNET = "http://ec2-44-200-18-204.compute-1.amazonaws.com:8545";
5+
public static readonly string NODEDEFAULT_ETH_ROPSTEN = "http://ec2-44-203-28-1.compute-1.amazonaws.com:8545";
6+
}
7+
}

Web3/Assets/EasyEthereum/Scripts/EasyWeb3Wallet.cs.meta renamed to Web3/Assets/EasyEthereum/Scripts/Constants.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Web3/Assets/EasyEthereum/Scripts/Contracts.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Numerics;
3+
using System.Threading.Tasks;
4+
using Nethereum.Web3;
5+
using Nethereum.Hex.HexTypes;
6+
using Nethereum.Hex.HexConvertors.Extensions;
7+
using Nethereum.JsonRpc.Client;
8+
using Nethereum.RPC.Eth.DTOs;
9+
10+
namespace EasyWeb3 {
11+
public class ERC20 : Contract {
12+
private string ERC20ABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"balance\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]";
13+
14+
public ERC20(string _contract, ChainName _n, ChainId _i) : base(_contract,_n,_i) {
15+
16+
}
17+
18+
public async Task<BigInteger> GetTotalSupply() {
19+
try {
20+
var _input = new CallInput(FunctionHash("totalSupply()"), m_Contract);
21+
var _result = await m_Web3.Eth.Transactions.Call.SendRequestAsync(_input);
22+
return (new HexBigInteger(_result)).Value;
23+
} catch (System.Exception _e) {
24+
LogWarning("[GetTotalSupply] Error: "+_e);
25+
return 0;
26+
}
27+
}
28+
}
29+
}

Web3/Assets/EasyEthereum/Scripts/Contracts/ERC20.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using System;
2+
3+
public class ERC721 {
4+
5+
}

Web3/Assets/EasyEthereum/Scripts/Contracts/ERC721.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using System;
4+
using System.Numerics;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using Nethereum.Web3;
8+
using Nethereum.Hex.HexTypes;
9+
using Nethereum.Hex.HexConvertors.Extensions;
10+
using Nethereum.RPC.Eth.Transactions;
11+
using Nethereum.JsonRpc.Client;
12+
using Nethereum.RPC.Eth.DTOs;
13+
using UnityEngine;
14+
15+
namespace EasyWeb3 {
16+
public class EasyWeb3Controller : MonoBehaviour
17+
{
18+
private Web3 m_Web3;
19+
20+
#region Unity Standard Functions
21+
private void Start() {
22+
Load();
23+
}
24+
#endregion
25+
26+
#region Public UI Accessor Functions
27+
28+
#endregion
29+
30+
#region Private Functions
31+
private async void Load() {
32+
ERC20 _token = new ERC20("0x1A2933fbA0c6e959c9A2D2c933f3f8AD4aa9f06e", ChainName.ETH, ChainId.ETH_MAINNET);
33+
BigInteger _totalSupply = await _token.GetTotalSupply();
34+
Debug.Log("total supply: "+_totalSupply);
35+
}
36+
37+
private async void GetChainId() {
38+
HexBigInteger _hex = await m_Web3.Eth.ChainId.SendRequestAsync();
39+
ulong _chain = (ulong)_hex.Value;
40+
Debug.Log("Chain: "+_chain);
41+
}
42+
43+
#endregion
44+
}
45+
}

Web3/Assets/EasyEthereum/Scripts/EasyWeb3Controller.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)