-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.rst
277 lines (192 loc) · 7.31 KB
/
README.rst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
🏗👷🏾 Moodyeth
============
Ether API for Python The only Library
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|moodyeth| |image1| |image2| |image3|
Ethereum based all Moody tool chain for smart contract development kit
`documentation <https://htmlpreview.github.io/?https://github.com/tokenchain/moodyeth/blob/main/docs/moody/index.html>`__.
Why do we use python
~~~~~~~~~~~~~~~~~~~~
Using it because it is fast and easy. More importantly it runs directly
by its own and no more dependencies.
Its much faster to building modules and calling functions on python.
Also it can be wrapped into an executable binary on wasm or cpython that
runs on natively any platforms.
If you are using PyCharm or similar IDE, all type are ready to show at
your finger tips.
Get Started
~~~~~~~~~~~
``pip3 install moodyeth``
or upgrade using
``sudo pip3 install moodyeth --upgrade``
or try this without vpn
``sudo pip3 install moodyeth --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple``
``sudo pip3 install moodyeth --upgrade -i https://pypi.python.org/simple``
The development of Moody contract deployment tools:
Setup (for the early version, we are going to setup the workspace
manually. )
Setup the folders: /vault /artifact /deploy_history /deploy_results
/factoryabi
Why use moody eth
~~~~~~~~~~~~~~~~~
It is a all-in-one package with zero setup and configurations that works
for multiple architectures. It is lightweight and simple. Build-in ERC20
support and bulk token sending support. Out of the box that comes with
solc-compile automation and web3 executions.
Features
~~~~~~~~
- support most of the evm compatible chains
- golang module compile support
- python module compile support
- typescript module compile support
- forge foundry support
- flashbots support
- implementation of contract upgradings
- upgrade contracts for 3 different ways
- Multicall3 interactions
Examples:
~~~~~~~~~
Deployment of the new contract:
'''''''''''''''''''''''''''''''
.. code:: python
# !/usr/bin/env python
# coding: utf-8
import os
from moody.libeb import MiliDoS
from moody import conf
privatekey = "xxxxxxxx"
# now using xDAI
network = conf.XDaiMainnet()
ROOT = os.path.join(os.path.dirname(__file__))
meta = MiliDoS(network).withPOA()
meta.setWorkspace(ROOT).Auth(privatekey)
meta.deploy("Ori20")
BSend add signer
^^^^^^^^^^^^^^^^
Adding signer using bsend
.. code:: python
# !/usr/bin/env python
# coding: utf-8
import os
from moody.libeb import MiliDoS
from moody import conf
privatekey = "xxxxxxxx"
# now using xDAI
network = conf.XDaiMainnet()
#gas and gas price configurations
meta.OverrideGasConfig(6000000, 2000000000)
ROOT = os.path.join(os.path.dirname(__file__))
meta = MiliDoS(network).withPOA().setWorkspace(ROOT).Auth(privatekey)
contract_address = "0x_________________"
signing_address = "0x________my_wallet"
expressContract = BSend(meta, contract_address).CallAutoConf(meta).CallDebug(True)
expressContract.add_signer(signing_address)
Mint Coins
^^^^^^^^^^
The example for minting coins with 18 decimal
.. code:: python
# !/usr/bin/env python
# coding: utf-8
import os
from moody.libeb import MiliDoS
from moody import conf
from moody.m.tc20 import Tc20
privatekey = "xxxxxxxx"
contract_address = "0x_________________"
my_wallet = "0x________my_wallet"
# now using xDAI
network = conf.XDaiMainnet()
#gas and gas price configurations
meta.OverrideGasConfig(6000000, 2000000000)
ROOT = os.path.join(os.path.dirname(__file__))
meta = MiliDoS(network).withPOA().setWorkspace(ROOT).Auth(privatekey)
tokenContract = Tc20(meta, contract_address).CallAutoConf(meta)
# assume this coin comes with 18 decimal
tokenContract.EnforceTxReceipt(True).mint(my_wallet, 300*10**18)
Example for compiling contracts with solc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: python
# !/usr/bin/env python
# coding: utf-8
from moody import conf, Evm
from moody.libeb import MiliDoS
ROOT = "my_workspace_path"
# as the solidity compiler version
SOLV = "0.8.6"
CONTRACT_LIST = [
"vault/folder1/xxx1.sol",
"vault/folder2/xxx2.sol",
"vault/folder2/xxx3.sol",
]
netcompile = conf.RSCMainnet()
r = MiliDoS(netcompile)
print("-----> the workspace location")
print(ROOT)
r.setWorkspace(ROOT).setOptimizationRuns(5000).setEvm(Evm.ISTANBUL).setClassSolNames(CONTRACT_LIST).remoteCompile(SOLV).localTranspile()
# Optionally you can directly call the execution to run the localtranspile
# r.setWorkspace(ROOT).setClassSolNames(CONTRACT_LIST).localTranspile()
# os.system("sh localpile")
Code compile
^^^^^^^^^^^^
The new build codebase all in the one take. In order to use this
feature, the required package will need to be installed to the system.
Otherwise the error message will show.
- factoryabi (source transpiler for ts and python)
- forge (solidity compiler)
- abigen (golang transpile generator)
- abi-gen-uni (transpiler consumer)
If you are all set, then you are ready to run the following code for
example:
.. code:: python
# !/usr/bin/env python
# coding: utf-8
import os
from moody.libeb import MiliDoS
from moody import Evm, conf
from key import ROOT
SOLV = "0.8.12"
C811 = [
"vault/token/RaceToken.sol",
]
network = conf.EthereumFL()
r = MiliDoS(network)
ROOT = '/.../Documents/b95/devmoody'
FACTORY = '$HOME/Documents/piplines/factoryabi'
r.brew(ROOT, FACTORY).setClassSolNames(C811).setEvm(Evm.ISTANBUL)
r.useForge().localTranspile()
Example for multicall
~~~~~~~~~~~~~~~~~~~~~
.. code:: python
from multicall import Call, Multicall
# assuming you are on kovan
MKR_TOKEN = '0xaaf64bfcc32d0f15873a02163e7e500671a4ffcd'
MKR_WHALE = '0xdb33dfd3d61308c33c63209845dad3e6bfb2c674'
MKR_FISH = '0x2dfcedcb401557354d0cf174876ab17bfd6f4efd'
def from_wei(value):
return value / 1e18
multi = Multicall([
Call(MKR_TOKEN, ['balanceOf(address)(uint256)', MKR_WHALE], [('whale', from_wei)]),
Call(MKR_TOKEN, ['balanceOf(address)(uint256)', MKR_FISH], [('fish', from_wei)]),
Call(MKR_TOKEN, 'totalSupply()(uint256)', [('supply', from_wei)]),
])
multi() # {'whale': 566437.0921992733, 'fish': 7005.0, 'supply': 1000003.1220798912}
# seth-style calls
Call(MKR_TOKEN, ['balanceOf(address)(uint256)', MKR_WHALE])()
Call(MKR_TOKEN, 'balanceOf(address)(uint256)')(MKR_WHALE)
# return values processing
Call(MKR_TOKEN, 'totalSupply()(uint256)', [('supply', from_wei)])()
Documentation is ready
`here <https://htmlpreview.github.io/?https://github.com/tokenchain/moodyeth/blob/main/docs/moody/index.html>`__
Also there is a brother library for those who works with
`Tron <https://github.com/tokenchain/tronpytool>`__ network.
Donations
~~~~~~~~~
Welcome for donation for the good works!
.. |moodyeth| image:: https://img.shields.io/pypi/v/moodyeth?style=plastic
:target: https://pypi.org/project/moodyeth/
.. |image1| image:: https://img.shields.io/pypi/pyversions/moodyeth.svg
:target: https://pypi.org/project/moodyeth/
.. |image2| image:: https://api.travis-ci.com/tokenchain/moodyeth.svg?branch=master
:target: https://pypi.org/project/moodyeth/
.. |image3| image:: https://img.shields.io/github/issues/tokenchain/moodyeth.svg
:target: https://pypi.org/project/moodyeth/