Skip to content

Commit af86300

Browse files
authored
Create README.md
1 parent 355fac2 commit af86300

File tree

1 file changed

+190
-0
lines changed

1 file changed

+190
-0
lines changed

README.md

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# easyweb3-unity
2+
3+
### PREFACE
4+
5+
This package was primed for the Unity Asset Store, but Unity mentioned to me that they want nothing to do with Web3 from their creators; and have since removed similar projects from their store.
6+
7+
For that reason I have no choice but to put this repo out into the wild, otherwise it will just collect dust.
8+
9+
This project is a comprehensive blockchain reader for any EVM chain. Due to massive security implications, there are no wallet management, key management, or transaction sender functions in here as it would likely compromise the players.
10+
11+
### UNITY SUPPORT
12+
13+
This package is compatible with Unity 2019.4.38f1 and higher.
14+
15+
### PACKAGE SUPPORT
16+
17+
I am here to look at pull requests and engage the community to make this a worthwhile project. If you have questions or feature requests please join the Discord https://discord.com/invite/3NV829ch76.
18+
19+
### Intro
20+
By using this asset you will easily be able to access data across three major blockchains; Ethereum, Binance Smart Chain, and Polygon. Everything will work out of the box as we provide test nodes for you to use. With Easy! Web3 you can continuously scan the chain to parse out transactions you care about, make complex custom contract calls, build ERC20 and ERC721 objects, quickly download player NFTs, and extend the base Contract class to support your own contracts.
21+
22+
### Free Nodes For Mainnets and Testnets
23+
You will be granted free access to use the nodes provided in this package. You can replace the node URLs by using an overloaded Contract constructor, explained in the API section of the PDF doc. You will be provided, out of the box, with the following blockchain access:
24+
Ethereum Mainnet
25+
Ethereum Ropsten Testnet
26+
Binance Smart Chain Mainnet
27+
Binance Smart Chain Testnet
28+
Polygon Mainnet
29+
Polygon Testnet
30+
31+
### Feature-Rich Demo Scene
32+
The demo scene will help you explore the possibilities of what you can do with this package. By studying it, you will understand how to test your blockchain functions, make custom smart contract calls, interact with standards like ERC-20 and ERC-721 (NFT), check user balances, enforce asset-based zones in-game, and scan the blockchain for any data you might need.
33+
34+
### UniswapV2 Scanner (Example Scanner)
35+
To encourage creativity around data scanning we provided an example scanner for UniswapV2 transactions. This continuously outputs all UniswapV2 swaps, liquidity adds, and liquidity removals to a textbox. Any contract or wallet address can be scanned, not just Uniswap!
36+
37+
### Custom Encoder & Decoder
38+
The encoder and decoder power this asset to provide one-liner custom contract calls. You effectively write pseudo-Solidity code to pull chain data. Look at all code examples in the PDF doc.
39+
```
40+
List<object> _outputs = await _contract.CallFunction("isBot(address)", new string[]{"bool"}, new string[]{"0x000...000"});
41+
bool _isBot = (bool)_outputs[0];
42+
```
43+
44+
### Trigger-Based NFT Loader
45+
By studying the TriggerNFTLoader.cs file from the demo you will learn how to access NFTs for your users.
46+
47+
### Trigger-Based Balance Action
48+
The TriggerBalanceAction.cs script is nice if you want to restrict areas of your game to users that hold a certain balance of a particular cryptocurrency.
49+
50+
# API
51+
52+
## ChainId
53+
A simple enumeration of supported chains.
54+
```
55+
ChainId.ETH_MAINNET
56+
ChainId.ETH_ROPSTEN
57+
ChainId.BSC_MAINNET
58+
ChainId.BSC_TESTNET
59+
ChainId.MATIC_MAINNET
60+
ChainId.MATIC_TESTNET
61+
```
62+
63+
## Web3ify
64+
Provides access to Nethereum’s web3 object for accessing the blockchain. Manages the node url.
65+
66+
```
67+
property ChainId chainId
68+
```
69+
70+
#### FUNCTIONS
71+
```
72+
async Task<BigInteger> GetChainId()
73+
async Task<Transaction> GetTransaction(_hash)
74+
async Task<TransactionReceipt> GetTransactionReceipt(_hash))
75+
async Task<HexBigInteger> GetBlockNumber()
76+
async Task<BlockWithTransactions> GetTransactionsOnBlock(_blockNum)
77+
async Task<List<Transaction>> ScanAll(_onScanComplete)
78+
```
79+
80+
## Web3Utils
81+
Provides an interface for conversions to and from hex and strings, addresses, and integers.
82+
83+
#### FUNCTIONS
84+
```
85+
static string FunctionHash(string)
86+
static string HexToString(string)
87+
static string HexAddressToString(string)
88+
static string AddressToHexString(string)
89+
static string StringToHexBigInteger(string)
90+
static string StringToHexString(string)
91+
```
92+
93+
## Contract
94+
Extends Web3ify. Provides custom contract call and blockchain scanning functionality for a given address. This class can be extended for any custom contract.
95+
```
96+
property BigInteger TotalSupply
97+
property BigInteger Decimals
98+
property string Name
99+
property string Owner
100+
property string Symbol
101+
```
102+
103+
#### FUNCTIONS
104+
```
105+
double ValueFromDecimals(_value)
106+
async Task<List<object>> CallFunction(string, string[], string[])
107+
async Task<List<Transaction>> Scan(_onScanComplete)
108+
```
109+
110+
## ERC20
111+
Extends Contract, which extends Web3ify. Provides a basic interface for calling ERC20 functions.
112+
113+
#### FUNCTIONS
114+
```
115+
async Task<bool> Load()
116+
async Task<BigInteger> GetTotalSupply()
117+
async Task<BigInteger> GetDecimals()
118+
async Task<string> GetName()
119+
async Task<string> GetSymbol()
120+
async Task<string> GetOwner()
121+
async Task<BigInteger> GetBalanceOf(_addr)
122+
async Task<BigInteger> GetAllowance(_owner, _spender)
123+
```
124+
125+
## ERC721
126+
Extends Contract, which extends Web3ify. Provides a basic interface for calling ERC721 functions.
127+
128+
#### FUNCTIONS
129+
```
130+
async Task<bool> Load()
131+
async Task<BigInteger> GetTotalSupply()
132+
async Task<string> GetName()
133+
async Task<string> GetSymbol()
134+
async Task<BigInteger> GetBalanceOf(_addr)
135+
async Task<BigInteger> GetTokenOfOwnerByIndex(_owner, _index)
136+
async Task<string> GetToken(_tokenId)
137+
async Task<string> GetOwnerOf(_tokenId)
138+
async Task<string> GetApproved(_tokenId)
139+
async Task<bool> IsApprovedForAll(_owner, _operator)
140+
async Task<List<NFT>> GetOwnerNFTs(_owner, _onProgress, _onFail)
141+
```
142+
143+
## NFT
144+
Provides a structure for NFT metadata to output to
145+
```
146+
property int Id
147+
property string Uri
148+
property NFTData Data
149+
```
150+
151+
## NFTData
152+
```
153+
property string title
154+
property string image
155+
property string name
156+
property string description
157+
property NFTAttribute[] attributes
158+
```
159+
160+
## NFTAttribute
161+
```
162+
property string trait_type
163+
property string value
164+
```
165+
166+
## Transaction
167+
Wraps around the Nethereum Transaction object. Provides more usability for decoding hex input data from blockchain transactions.
168+
```
169+
property string MethodId
170+
property Transaction Data
171+
```
172+
173+
#### FUNCTIONS
174+
```
175+
List<object> GetInputs(string[])
176+
```
177+
178+
## Wallet
179+
Provides a quick interface for grabbing native and ERC-20 balances for a given address.
180+
181+
```
182+
property string ShortAddress
183+
```
184+
185+
#### FUNCTIONS
186+
```
187+
async Task<double> GetNativeBalance()
188+
async Task<double> GetERC20Balance(_contract)
189+
async Task<BigInteger> GetTransactionCount()
190+
```

0 commit comments

Comments
 (0)