Beispiel #1
0
    for i in xrange(20):
        unreg_data.append(gen_random_unreg_data())

    with open("unreg_data.json", "w") as fp:
        fp.write(json.dumps(unreg_data, indent=2, cls=ByteArrayEncoder))
else:
    with open("unreg_data.json", "r") as fp:
        unreg_data = json.loads(fp.read())

m = Mallmann()
m = m.add_contract("eosio", "eosio.system.abi")
m = m.add_contract("eosio.token", "eosio.token.abi")
m = m.add_contract("eosio.unregd", unregd_abi)

# Tx1 (eosio.unregd/eosio.regram creation)
m = m.expires_in(days=5)
m = m.auth("eosio", "active")
m = m.eosio.newaccount("eosio", "eosio.unregd", eosio_active, eosio_active)
m = m.eosio.buyrambytes("eosio", "eosio.unregd", 1200 * 1024)  # 1.2M
m = m.eosio.delegatebw("eosio", "eosio.unregd", "2.0000 EOS", "2.0000 EOS",
                       True)
m = m.eosio.newaccount("eosio", "eosio.regram", eosio_active, eosio_active)
m = m.eosio.buyrambytes("eosio", "eosio.regram", 4 * 1024)  # 4K
m = m.eosio.delegatebw("eosio", "eosio.regram", "2.0000 EOS", "2.0000 EOS",
                       True)

with open("tx1.json", "w") as fp:
    p1 = propose.copy()
    p1["trx"] = m.get_tx().copy()
    p1["proposal_name"] = "eosiounregd1"
    fp.write(json.dumps(p1, indent=2, cls=ByteArrayEncoder))
Beispiel #2
0
#!/usr/bin/env python
import sys
sys.path.append("..")

from mallmann import Mallmann

if len(sys.argv) < 3:
    print "usage: punga.py ACCOUNT_NAME EOS_AMOUNT"
    sys.exit(1)

account = sys.argv[1]
amount = sys.argv[2]

m = Mallmann()
m = m.expires_in(hours=1)
m = m.add_contract("eosio", "eosio.system.abi")
m = m.add_contract("eosio.token", "eosio.token.abi")
m = m.auth("eosio.prods", "active")
m = m.eosio.setcode("eosio.prods", 0, 0, m.load_code("forward"))
m = m.auth("eosio", "active")
m = m.eosio.setpriv("eosio.prods", 1)
m = m.eosio_prods.raw_call(
    m.action_to_hex(
        m.get_contract("eosio.token").call_action("transfer",
                                                  (account, "active"), account,
                                                  "eosio", amount,
                                                  "-=PuNGA=-")))
m = m.auth("eosio.prods", "active")
m = m.eosio.setcode("eosio.prods", 0, 0, m.load_code("void"))
m = m.auth("eosio", "active")
m = m.eosio.setpriv("eosio.prods", 0)
                              json=True)["rows"]:
    propose["requested"].append({"actor": r["owner"], "permission": "active"})

# Craft setcode/setabi tx
with open(unregd_wasm, "rb") as fp:
    wasm = fp.read()

m = Mallmann()
m = m.add_contract("eosio.unregd", unregd_abi)

abi = m.get_contract("eosio.unregd").abis.abi_to_bin()

print("sha256(wasm) = {0}".format(sha256(wasm).digest().hex()))
print("sha256(abi) = {0}".format(sha256(abi).digest().hex()))

# Tx2 (setcode/setabi eosio.unregd)
m = m.expires_in(days=15)
m = m.add_contract("eosio", "eosio.system.abi")
m = m.auth("eosio.unregd", "active")
m = m.eosio.setcode("eosio.unregd", 0, 0, wasm)
m = m.eosio.setabi("eosio.unregd", abi)

with open("tx-newunregdupd.json", "w") as fp:
    p2 = propose.copy()
    p2["trx"] = m.get_tx().copy()
    p2["proposal_name"] = "newunregdupd"
    fp.write(json.dumps(p2, indent=2, cls=ByteArrayEncoder))
    print("tx-newunregdupd.json generated ...")

print("done")