Deploy script to package, dockerfile

This commit is contained in:
nolash 2020-12-01 23:54:17 +01:00
parent 4d72398adf
commit 27ea14772f
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
11 changed files with 76 additions and 49 deletions

28
Dockerfile Normal file
View File

@ -0,0 +1,28 @@
FROM ethereum/solc:0.6.12
FROM python:3.8.6-alpine
COPY --from=0 /usr/bin/solc /usr/bin/solc
RUN apk update &&\
apk add gcc bash musl-dev
WORKDIR /usr/src
# Try to keep everything above here re-usable!
COPY ./solidity/ /usr/src/giftable_erc20_token/solidity/
COPY ./python/ /usr/src/giftable_erc20_token/python/
RUN cd giftable_erc20_token/solidity && \
solc GiftableToken.sol --abi | awk 'NR>3' > GiftableToken.abi.json
RUN cd giftable_erc20_token/solidity && \
solc GiftableToken.sol --bin | awk 'NR>3' > GiftableToken.bin && \
truncate -s "$((`stat -t -c "%s" GiftableToken.bin`-1))" GiftableToken.bin
RUN cd giftable_erc20_token/python && \
pip install --extra-index-url https://pip.grassrootseconomics.net:8433 .
# To deploy:
# giftable-token-deploy --contracts-dir giftable_erc20_token/solidity/ <amount>

45
LICENSE
View File

@ -1,45 +0,0 @@
Bprotocol Foundation (Bancor) LICENSE
1. SUBJECT TO THE PROVISIONS SET FORTH HEREIN, INCLUDING “EFFECTIVE DATE”, YOU CAN
USE THIS CODE, FILE AND/OR SOFTWARE (“SOFTWARE”) ONLY IN CONNECTION WITH THE
BANCOR LIQUIDITY NETWORK AND/OR THE USE OF BNT ("PERMITTED USE"). ANY OTHER USE IS
PROHIBITED UNLESS THE USER SHALL RECEIVE AN EXPLICIT PRIOR WRITTEN APPROVAL FROM
BPROTOCOL FOUNDATION (BANCOR) TO DO SO (PLEASE CONTACT license@bancor.network IN
THIS REGARD), WHICH APPROVAL, IF GIVEN, MAY REQUIRE THE OBTAINMENT OF SEPARATE
LICENSE UNDER A DIFFERENT LICENSING MODEL. USING THIS SOFTWARE NOT IN THE FRAME OF
SUCH PERMITTED USE MAY, AMONG OTHERS, ALSO BREACH PATENT RIGHTS CONCERNING PATENTS
WHICH ARE EMBODIED/INCORPORATED/USED IN THIS SOFTWARE.
2. ANY SUCH PERMITTED USE SHOULD ALSO COMPLY WITH THE TERMS BELOW.
3. Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
A. Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
B. Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
C. Neither the name of the copyright holder nor the names of its contributors may be
used to endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EFFECTIVE DATE: THIS LICENSE SHALL APPLY ONLY TO SOFTWARE (OR ANY VERSION THEREOF),
THAT HAS BEEN PUBLISHED AFTER THE DATE AND TIME THIS LICENSE HAS BEEN FIRST PUBLISHED
(“EFFECTIVE DATE”); Any previous versions published prior to the effective date (“Older Versions”)
shall remain licensed under the Apache License, Version 2.0 (the "Older Versions License");
You may obtain a copy of the Older Version License at http://www.apache.org/licenses/LICENSE-2.0
you may not use this file except in compliance with the Older Version License. Unless
required by applicable law or agreed to in writing, Older Versions distributed under the
Older Version License are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the Older Version License for the specific
language governing permissions and limitations under the Older Version License.

View File

@ -1,3 +1,5 @@
* 0.0.2
- Move deploy script to package
* 0.0.1 * 0.0.1
- Adapt Bancor ERC20 token contract - Adapt Bancor ERC20 token contract
- Add deploy-and-gift script - Add deploy-and-gift script

View File

@ -8,6 +8,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
# standard imports # standard imports
import os
import json import json
import argparse import argparse
import logging import logging
@ -28,6 +29,7 @@ argparser.add_argument('-n', '--name', dest='n', default='Giftable Token', type=
argparser.add_argument('-s', '--symbol', dest='s', default='GFT', type=str, help='Token symbol') argparser.add_argument('-s', '--symbol', dest='s', default='GFT', type=str, help='Token symbol')
argparser.add_argument('-d', '--decimals', dest='d', default=18, type=int, help='Token decimals') argparser.add_argument('-d', '--decimals', dest='d', default=18, type=int, help='Token decimals')
argparser.add_argument('-a', '--account', dest='a', action='append', type=str, help='Account to fund') argparser.add_argument('-a', '--account', dest='a', action='append', type=str, help='Account to fund')
argparser.add_argument('--contracts-dir', dest='contracts_dir', type=str, default='.', help='Directory containing bytecode and abi')
argparser.add_argument('-v', action='store_true', help='Be verbose') argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('amount', type=int, help='Initial token supply (will be owned by contract creator)') argparser.add_argument('amount', type=int, help='Initial token supply (will be owned by contract creator)')
args = argparser.parse_args() args = argparser.parse_args()
@ -35,14 +37,14 @@ args = argparser.parse_args()
if args.v: if args.v:
logg.setLevel(logging.DEBUG) logg.setLevel(logging.DEBUG)
if __name__ == '__main__': def main():
w3 = web3.Web3(web3.Web3.HTTPProvider(args.p)) w3 = web3.Web3(web3.Web3.HTTPProvider(args.p))
f = open('./GiftableToken.abi.json', 'r') f = open(os.path.join(args.contracts_dir, 'GiftableToken.abi.json'), 'r')
abi = json.load(f) abi = json.load(f)
f.close() f.close()
f = open('./GiftableToken.bin', 'r') f = open(os.path.join(args.contracts_dir, 'GiftableToken.bin'), 'r')
bytecode = f.read() bytecode = f.read()
f.close() f.close()
@ -69,3 +71,7 @@ if __name__ == '__main__':
logg.info('balance {}: {}'.format(a, balance)) logg.info('balance {}: {}'.format(a, balance))
print(address) print(address)
if __name__ == '__main__':
main()

32
python/setup.cfg Normal file
View File

@ -0,0 +1,32 @@
[metadata]
name = giftable-erc20-token
version = 0.0.2
description = Simple ERC20 contract with deployment script that lets any address mint and gift itself tokens.
author = Louis Holbrook
author_email = dev@holbrook.no
url = https://gitlab.com/nolash/giftable-erc-token
keywords =
ethereum
classifiers =
Programming Language :: Python :: 3
Operating System :: OS Independent
Development Status :: 3 - Alpha
Environment :: No Input/Output (Daemon)
Intended Audience :: Developers
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Topic :: Internet
#Topic :: Blockchain :: EVM
license = GPL3
licence_files =
LICENSE
[options]
python_requires = >= 3.6
packages =
giftable_erc20_token.runnable
install_requires =
web3==5.12.2
[options.entry_points]
console_scripts =
giftable-token-deploy = giftable_erc20_token.runnable.deploy:main

4
python/setup.py Normal file
View File

@ -0,0 +1,4 @@
from setuptools import setup
setup(
)

View File

@ -48,7 +48,7 @@ contract GiftableToken { //is IERC20Token, Utils {
* @param _decimals decimal points, for display purposes * @param _decimals decimal points, for display purposes
* @param _initialSupply total supply of token units * @param _initialSupply total supply of token units
*/ */
constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _initialSupply) { constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _initialSupply) public {
// validate input // validate input
require(bytes(_name).length > 0, "ERR_INVALID_NAME"); require(bytes(_name).length > 0, "ERR_INVALID_NAME");
require(bytes(_symbol).length > 0, "ERR_INVALID_SYMBOL"); require(bytes(_symbol).length > 0, "ERR_INVALID_SYMBOL");