baking-bad / pytezos Goto Github PK
View Code? Open in Web Editor NEWThis project forked from murbard/pytezos
๐ Python SDK for Tezos | Michelson VM in Python
Home Page: https://pytezos.org
License: MIT License
This project forked from murbard/pytezos
๐ Python SDK for Tezos | Michelson VM in Python
Home Page: https://pytezos.org
License: MIT License
## There is nat 44 and nat 33 on the stack
PACK ;
SWAP ;
PACK ;
CONCAT ;
UNPACK nat ;
Should be None
but it gives Some 33
instead (need to check data length)
>>> mainnet.blocks[136137]()['header']
{'level': 136137, 'proto': 2, 'predecessor': 'BLrBTWHYsUtc5jrnSGsUAT6RmJcorqTpJ149XW32SNoXYa87GDS', 'timestamp': '2018-10-08T03:00:17Z', 'validation_pass': 4, 'operations_hash': 'LLoZsqNbazos3iu7ciThrX16rzmSKEeR2QqQ9Zf5czVQ8RPn9gfB2', 'fitness': ['00', '00000000003c45ff'], 'context': 'CoVEhhZtDQPYMxCabYRJcF3sw6XjAo4LGRzfaTYX86WN5mcC3LN8', 'priority': 0, 'proof_of_work_nonce': '02181b433147a93f', 'signature': 'sigZwRZSmNY7ZaT1oWddBGVTNB9vLSFhCeyFvrBEgNsAmRwARm8DgVjVbjq1UuUZHSnbsXUtkRU39JVM2mJn8psLzHo64qH7'}
but
>>> mainnet.blocks[136137].header()
{'protocol': 'PrihK96nBAFSxVL1GLJTVhu9YnzkMFiBeuJRPA8NwuZVZCE1L6i', 'chain_id': 'NetXdQprcVkpaWU', 'hash': 'BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2', 'level': 0, 'proto': 0, 'predecessor': 'BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2', 'timestamp': '2018-06-30T16:07:32Z', 'validation_pass': 0, 'operations_hash': 'LLoZS2LW3rEi7KYU4ouBQtorua37aWWCtpDmv1n2x3xoKi6sVXLWp', 'fitness': [], 'context': 'CoV8SQumiVU9saiu3FVNeDNewJaJH8yWdsGF3WLdsRr2P9S7MzCj'}
Trying the MichelsonParser class in pytezos:
p = pytezos.michelson.grammar.MichelsonParser()
p.parse('Pair 1 2')
yields
{'prim': 'Pair', 'args': [{'int': '1'}, {'int': '2'}]}
This ignores the possibility that the integers may refer to types or bigmaps... I understand this is just the parsing step, but how does one get further and get a "real" python value out of storage and the type of storage?
int_to_bytes encodes integer to bytes. sign method of Key class in crypto.py concatenates int_to_bytes(r) and int_to_bytes(s). If integer fits into less than 32 bytes, int_to_bytes returns less than 32 bytes, and signature becomes shorter than 64 bytes. Then base58 encoding fails as lengths don't match. You need to left-pad anything returned from int_to_bytes which is shorter than 32 bytes with zeroes when forming signature bytes.
Hello,
I have a simple SmartContract in Michelson with two entrypoints : mul_a_b and mul_c_d.
parameter (or (pair %mul_a_b (int %a) (int %b)) (pair %mul_c_d (int %c) (int %d))) ;
storage int ;
code { DUP ;
CDR ;
SWAP ;
CAR ;
IF_LEFT
{ PAIR ; DUP ; DUP ; CAR; CDR ; SWAP ; CAR; CAR ; MUL ; SWAP ; DROP }
{ PAIR ; DUP ; DUP ; CAR; CDR ; SWAP ; CAR; CAR ; MUL ; SWAP ; DROP } ;
NIL operation ;
PAIR }
Then, I defined a simple test :
from os.path import dirname, join
from unittest import TestCase
from pytezos import ContractInterface, MichelsonRuntimeError
project_dir = dirname(dirname(__file__))
class HelloWorldContractTest(TestCase):
@classmethod
def setUpClass(cls):
cls.helloWorld = ContractInterface.create_from(join(project_dir, 'src/helloWorldCode.tz'), shell='sandboxnet')
def test_mul_a_b(self):
res = self.helloWorld \
.mul_a_b(a=2, b=3) \
.result(storage=0)
self.assertEqual(6, res.storage)
So, It was working fine with pytezos-2.0.8 but I upgraded to pytezos-2.1.0 but now I have the error pytezos.rpc.node.RpcError: ('Json_encoding.Unexpected_field("entrypoint")',)
when I run the test :
What should I do ?
Reproduce:
.result()
then .inject()
or .result()
then .interpret()
Typical case if wrong network
https://michelson.nomadic-labs.com/#type-address
Decode as contract
Do not cache mempool queries
Including micheline expressions
SLICE ing 0 characters from the empty string results in None (and not Some ""). It seems consistent with the documentation but might be confusing.
PUSH timestamp "2020-06-17 10:00:00"
Sort maps/sets/big_maps and check for order
Hello,
import smartpy as sp
class MapInBigMap(sp.Contract):
"""
Type :
users_fruits_map : (key = string, value = map(string, int))
value : int
Example :
users_fruits_map = {
"Alice": {
"BANANA": 1,
"TOMATO": 2
},
...
}
value = 0
"""
def __init__(self):
self.init(users_fruits_map=sp.BigMap(), value=0)
"""
params.user: string
params.fruit: string
params.number: int
"""
@sp.entryPoint
def set_fruit_number_for_user(self, params):
sp.setType(params.user, sp.TSimple("string"))
sp.setType(params.fruit, sp.TSimple("string"))
sp.setType(params.number, sp.TSimple("int"))
self.data.users_fruits_map[params.user] = sp.Map()
self.data.users_fruits_map[params.user][params.fruit] = params.number
"""
value: int
"""
@sp.entryPoint
def set_value(self, value):
sp.setType(value, sp.TSimple("int"))
self.value = value
parameter (or (pair %set_fruit_number_for_user (pair (string %fruit) (int %number)) (string %user)) (int %set_value));
storage (pair (big_map string (map string int)) int);
code
{
DUP; # pair(params, storage).pair(params, storage)
CDR; # storage.pair(params, storage)
SWAP; # pair(params, storage).storage
CAR; # params.storage
IF_LEFT
{
# Entry point: set_fruit_number_for_user # pair %set_fruit_number_for_user (pair (string %fruit) (int %number)) (string %user).storage
PAIR; # pair(params, storage)
# self.data.users_fruits_map[params.user] = {} # pair(params, storage)
DUP; # pair(params, storage).pair(params, storage)
CDR; # storage.pair(params, storage)
DUP; # storage.storage.pair(params, storage)
DIP
{
DUUP; # pair(params, storage).storage.pair(params, storage)
}; # storage.pair(params, storage).storage.pair(params, storage)
CAR; # big_map string (map string int).pair(params, storage).storage.pair(params, storage)
SWAP; # pair(params, storage).big_map string (map string int).storage.pair(params, storage)
CADR; # string.big_map string (map string int).storage.pair(params, storage)
PUSH (option (map string int)) (Some {}); # option (map string int).string.big_map string (map string int).storage.pair(params, storage)
SWAP; # string.option (map string int).big_map string (map string int).storage.pair(params, storage)
UPDATE; # big_map string (map string int).storage.pair(params, storage)
SWAP; # storage.big_map string (map string int).pair(params, storage)
CDR; # int.big_map string (map string int).pair(params, storage)
SWAP; # big_map string (map string int).int.pair(params, storage)
PAIR; # pair (big_map string (map string int)) int.pair(params, storage)
SWAP; # pair(params, storage).pair (big_map string (map string int)) int
CAR; # pair (pair (string %fruit) (int %number)) (string %user).pair (big_map string (map string int)) int
PAIR; # pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
# self.data.users_fruits_map[params.user][params.fruit] = params.number # pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
DUP; # pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int).pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
CDR; # pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
DUP; # pair (big_map string (map string int)) int.pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
DIP
{
DUUP; # pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
}; # pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
CAR; # big_map string (map string int).pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
SWAP; # pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int).big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
CADR; # string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
PAIR; # pair string (big_map string (map string int)).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
DUP; # pair string (big_map string (map string int)).pair string (big_map string (map string int)).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
DIP
{
DUP; # pair string (big_map string (map string int)).pair string (big_map string (map string int)).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
CDR; # big_map string (map string int).pair string (big_map string (map string int)).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
SWAP; # pair string (big_map string (map string int)).big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
CAR; # string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
}; # pair string (big_map string (map string int)).string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
DUP; # pair string (big_map string (map string int)).pair string (big_map string (map string int)).string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
CDR; # big_map string (map string int).pair string (big_map string (map string int)).string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
SWAP; # pair string (big_map string (map string int)).big_map string (map string int).string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
CAR; # string.big_map string (map string int).string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
GET; # option (map string int).string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
IF_SOME
{}
{
FAIL; # FAILED
}; # map string int.string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
DUUUUUP; # pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int).map string int.string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
CAADR; # int.map string int.string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
SOME; # option int.map string int.string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
DUUUUUUP; # pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int).option int.map string int.string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
CAAAR; # string.option int.map string int.string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
UPDATE; # map string int.string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
SOME; # option (map string int).string.big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
SWAP; # string.option (map string int).big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
UPDATE; # big_map string (map string int).pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
SWAP; # pair (big_map string (map string int)) int.big_map string (map string int).pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
CDR; # int.big_map string (map string int).pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
SWAP; # big_map string (map string int).int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
PAIR; # pair (big_map string (map string int)) int.pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int)
SWAP; # pair (pair (pair (string %fruit) (int %number)) (string %user)) (pair (big_map string (map string int)) int).pair (big_map string (map string int)) int
DROP; # pair (big_map string (map string int)) int
}
{
# Entry point: set_value # int %set_value.storage
DROP; # storage
}; # pair (big_map string (map string int)) int
NIL operation; # list operation.pair (big_map string (map string int)) int
PAIR; # pair (list operation) (pair (big_map string (map string int)) int)
} # pair (list operation) (pair (big_map string (map string int)) int)
from os.path import dirname, join
from unittest import TestCase
from pytezos import ContractInterface, MichelsonRuntimeError
project_dir = dirname(dirname(__file__))
class MapInBigMapTest(TestCase):
@classmethod
def setUpClass(cls):
cls.map_in_big_map_contract = ContractInterface.create_from(join(project_dir, "generated/MapInBigMapCode.tz"))
def test_set_fruit_number_for_user_should_set_nb_bananas_for_user(self):
# Given
user = "Alice"
fruit = "BANANA"
number = 5
# When
res = self.map_in_big_map_contract.set_fruit_number_for_user(
user=user,
fruit=fruit,
number=number
).result(storage=[{}, 0])
# Then
self.assertEqual([{"Alice": {"BANANA": 5}}, 0], res.storage)
But it seems like the storage has not been updated when I run the test, it stays empty :
To be honest, I don't know if this behaviour come from pytezos or SmartPy or anything else...
I used pytezos-2.1.3.
Hello, I wrote a small test for testing my contract. (The contract is a simple fungible token ... the mint function takes mintOwner and mintValue as parameters).
Here is my test:
from os.path import dirname, join
from unittest import TestCase
from pytezos import ContractInterface
class HelloWorldContractTest(TestCase):
@classmethod
def setUpClass(cls):
project_dir = dirname(dirname(__file__))
print("projectdir", project_dir)
cls.token_v3 = ContractInterface.create_from(join(project_dir, 'src/token_v3.tz'))
def test_mint(self):
alice = "tz1ibMpWS6n6MJn73nQHtK5f4ogyYC1z9T9z"
val = 3
result = self.token_v3.mint(
mintOwner=alice,
mintValue=val
).result(
storage={
"admin": alice,
"balances": { },
"paused": False,
"shareType": "APPLE",
"totalSupply": 0
},
source=alice
)
It ends up with following error:
pytezos.michelson.converter.MichelineSchemaError: ('Failed to decode micheline expression', {'int': '3'})
... as you can see it tries to interpret { 'int', '3' } ... which is very strange because my calling parameters contains 2 named parameter mintOwner and mintValue.
Now if change just one letter of my parameter name (for example mintOwner to mintowner) in the invocation call like this
result = self.token_v3.mint( mintowner=alice, mintValue=val ).result(...)
It produces following error :
('Failed to encode micheline expression', {'mintowner': 'tz1ibMpWS6n6MJn73nQHtK5f4ogyYC1z9T9z', 'mintValue': 3})
... now it understand there is a record containing 2 fields.
How can I make this test work ? How do I specify my parameters ?
my contract is a bit long. ... sorry
{ parameter
(or (or (or (pair %burn (nat %burnValue) (address %owner))
(pair %mint (address %mintOwner) (nat %mintValue)))
(or (bool %pause) (address %setAdmin)))
(pair %transfer (pair (address %fromOwner) (address %toOwner)) (nat %value))) ;
storage
(pair (pair (pair (address %admin) (big_map %balances address nat))
(pair (bool %paused) (string %shareType)))
(nat %totalSupply)) ;
code { LAMBDA
(pair address (pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
bool
{ DUP ;
CAR ;
DIP { DUP } ;
SWAP ;
CDR ;
DIP { DUP } ;
SWAP ;
DIP { DUP ; CAR ; CAR ; CAR } ;
COMPARE ;
EQ ;
DIP { DROP 3 } } ;
DUP ;
LAMBDA
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat)
bool
{ DUP ; CAR ; CDR ; CAR ; DIP { DROP } } ;
SWAP ;
LAMBDA
(pair (lambda
(pair address (pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
bool)
(pair address (pair (pair (pair address (big_map address nat)) (pair bool string)) nat)))
(pair (list operation)
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
{ DUP ;
CAR ;
SWAP ;
CDR ;
DUP ;
CAR ;
DIP { DUP } ;
SWAP ;
CDR ;
DUP ;
SENDER ;
PAIR ;
DIP { DIP 3 { DUP } ; DIG 3 } ;
EXEC ;
DUP ;
IF { DIP 2 { DUP } ;
DIG 2 ;
DIP { DIP { DUP } ;
SWAP ;
DUP ;
CDR ;
SWAP ;
CAR ;
DUP ;
CDR ;
SWAP ;
CAR ;
CDR } ;
PAIR ;
PAIR ;
PAIR ;
SWAP ;
DIP { DIP { DROP } } ;
PUSH unit Unit }
{ PUSH string "[set_admin] need admin privileges" ; FAILWITH } ;
DROP ;
DIP { DUP } ;
SWAP ;
NIL operation ;
PAIR ;
DIP { DROP 5 } } ;
SWAP ;
APPLY ;
DIP { DIP { DUP } ; DUP ; DIP { PAIR } ; SWAP } ;
SWAP ;
LAMBDA
(pair (pair address nat)
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat)
{ DUP ;
CAR ;
CAR ;
DIP { DUP } ;
SWAP ;
CAR ;
CDR ;
DIP 2 { DUP } ;
DIG 2 ;
CDR ;
DUP ;
CAR ;
CAR ;
CDR ;
DIP 3 { DUP } ;
DIG 3 ;
DIP { DIP { DUP } ; SWAP ; CAR ; CAR ; CDR } ;
GET ;
DUP ;
PUSH nat 0 ;
SWAP ;
IF_NONE
{ DIP 4 { DUP } ; DIG 4 ; DIP { DROP } ; PUSH unit Unit }
{ DUP ;
DIP { DIP 5 { DUP } ; DIG 5 } ;
ADD ;
DIP { DIP { DUP } ; SWAP ; DROP } ;
SWAP ;
DROP ;
DIP { DROP } ;
PUSH unit Unit } ;
DROP ;
DIP 5 { DUP } ;
DIG 5 ;
DIP { DUP ; SOME ; DIP { DIP 3 { DUP } ; DIG 3 ; CAR ; CAR ; CDR } } ;
UPDATE ;
DIP { DIP 3 { DUP } ;
DIG 3 ;
DUP ;
CDR ;
SWAP ;
CAR ;
DUP ;
CDR ;
SWAP ;
CAR ;
CAR } ;
SWAP ;
PAIR ;
PAIR ;
PAIR ;
DIP 4 { DROP } ;
DUG 3 ;
DIP 3 { DUP } ;
DIG 3 ;
CDR ;
DIP { DIP 4 { DUP } ; DIG 4 } ;
ADD ;
DIP { DIP 3 { DUP } ; DIG 3 ; CAR } ;
SWAP ;
PAIR ;
DIP 4 { DROP } ;
DUG 3 ;
DIP 3 { DUP } ;
DIG 3 ;
DIP { DROP 7 } } ;
DUP ;
DIP { PAIR } ;
SWAP ;
LAMBDA
(pair (pair (lambda
(pair (pair address nat)
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
(pair (lambda (pair (pair (pair address (big_map address nat)) (pair bool string)) nat) bool)
(lambda
(pair address (pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
bool)))
(pair (pair address nat)
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat)))
(pair (list operation)
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
{ DUP ;
CAR ;
SWAP ;
CDR ;
DIP { DUP ; CDR ; SWAP ; CAR ; DIP { DUP ; CDR ; SWAP ; CAR } } ;
DUP ;
CAR ;
CAR ;
DIP { DUP } ;
SWAP ;
CAR ;
CDR ;
DIP 2 { DUP } ;
DIG 2 ;
CDR ;
DUP ;
DIP { DIP 5 { DUP } ; DIG 5 } ;
EXEC ;
DUP ;
IF { PUSH string "[mint] contract is paused" ; FAILWITH }
{ PUSH unit Unit } ;
DROP ;
DIP { DUP } ;
SWAP ;
SENDER ;
PAIR ;
DIP { DIP 7 { DUP } ; DIG 7 } ;
EXEC ;
DUP ;
IF { PUSH unit Unit }
{ PUSH string "[mint] need admin privileges" ; FAILWITH } ;
DROP ;
DIP 3 { DUP } ;
DIG 3 ;
PUSH nat 0 ;
SWAP ;
COMPARE ;
GT ;
DUP ;
IF { PUSH unit Unit }
{ PUSH string "[mint] value must be positive" ; FAILWITH } ;
DROP ;
DIP 5 { DUP } ;
DIG 5 ;
DIP { DIP 4 { DUP } ; DIG 4 } ;
PAIR ;
DIP { DIP 3 { DUP } ; DIG 3 } ;
PAIR ;
DIP { DIP 7 { DUP } ; DIG 7 } ;
EXEC ;
DIP { DIP 3 { DUP } ; DIG 3 ; DROP } ;
DIP 4 { DROP } ;
DUG 3 ;
DIP 3 { DUP } ;
DIG 3 ;
NIL operation ;
PAIR ;
DIP { DROP 10 } } ;
SWAP ;
APPLY ;
DIP { DIP { DIP { DIP { DUP } ; DUP ; DIP { PAIR } ; SWAP } ; SWAP } ;
SWAP } ;
SWAP ;
LAMBDA
(pair (pair address nat)
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat)
{ DUP ;
CAR ;
CAR ;
DIP { DUP } ;
SWAP ;
CAR ;
CDR ;
DIP 2 { DUP } ;
DIG 2 ;
CDR ;
DUP ;
CAR ;
CAR ;
CDR ;
DIP 3 { DUP } ;
DIG 3 ;
DIP { DIP { DUP } ; SWAP ; CAR ; CAR ; CDR } ;
GET ;
DUP ;
PUSH nat 0 ;
SWAP ;
IF_NONE
{ PUSH string "[doBurn] unknown owner" ; FAILWITH }
{ DUP ;
DUP ;
DIP { DIP 6 { DUP } ; DIG 6 } ;
COMPARE ;
GE ;
DUP ;
IF { DIP 2 { DUP } ;
DIG 2 ;
DIP { DIP 7 { DUP } ; DIG 7 } ;
SUB ;
ABS ;
DIP { DIP 3 { DUP } ; DIG 3 ; DROP } ;
DIP 4 { DROP } ;
DUG 3 ;
PUSH unit Unit }
{ PUSH string "[doBurn] not enough to burn" ; FAILWITH } ;
DIP { DROP 3 } } ;
DROP ;
DIP 5 { DUP } ;
DIG 5 ;
DIP { DUP ; SOME ; DIP { DIP 3 { DUP } ; DIG 3 ; CAR ; CAR ; CDR } } ;
UPDATE ;
DIP { DIP 3 { DUP } ;
DIG 3 ;
DUP ;
CDR ;
SWAP ;
CAR ;
DUP ;
CDR ;
SWAP ;
CAR ;
CAR } ;
SWAP ;
PAIR ;
PAIR ;
PAIR ;
DIP 4 { DROP } ;
DUG 3 ;
DIP 3 { DUP } ;
DIG 3 ;
CDR ;
DIP { DIP 4 { DUP } ; DIG 4 } ;
SUB ;
ABS ;
DIP { DIP 3 { DUP } ; DIG 3 ; CAR } ;
SWAP ;
PAIR ;
DIP 4 { DROP } ;
DUG 3 ;
DIP 3 { DUP } ;
DIG 3 ;
DIP { DROP 7 } } ;
DUP ;
DIP { PAIR } ;
SWAP ;
LAMBDA
(pair (pair (lambda
(pair (pair address nat)
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
(pair (lambda (pair (pair (pair address (big_map address nat)) (pair bool string)) nat) bool)
(lambda
(pair address (pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
bool)))
(pair (pair address nat)
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat)))
(pair (list operation)
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
{ DUP ;
CAR ;
SWAP ;
CDR ;
DIP { DUP ; CDR ; SWAP ; CAR ; DIP { DUP ; CDR ; SWAP ; CAR } } ;
DUP ;
CAR ;
CAR ;
DIP { DUP } ;
SWAP ;
CAR ;
CDR ;
DIP 2 { DUP } ;
DIG 2 ;
CDR ;
DUP ;
DIP { DIP 5 { DUP } ; DIG 5 } ;
EXEC ;
DUP ;
IF { PUSH string "[burn] contract is paused" ; FAILWITH }
{ PUSH unit Unit } ;
DROP ;
DIP { DUP } ;
SWAP ;
SENDER ;
PAIR ;
DIP { DIP 7 { DUP } ; DIG 7 } ;
EXEC ;
DUP ;
IF { PUSH unit Unit }
{ PUSH string "[burn] need admin privileges" ; FAILWITH } ;
DROP ;
DIP 3 { DUP } ;
DIG 3 ;
PUSH nat 0 ;
SWAP ;
COMPARE ;
GT ;
DUP ;
IF { PUSH unit Unit }
{ PUSH string "[burn] value must be positive" ; FAILWITH } ;
DROP ;
DIP 5 { DUP } ;
DIG 5 ;
DIP { DIP 4 { DUP } ; DIG 4 } ;
PAIR ;
DIP { DIP 3 { DUP } ; DIG 3 } ;
PAIR ;
DIP { DIP 7 { DUP } ; DIG 7 } ;
EXEC ;
DIP { DIP 3 { DUP } ; DIG 3 ; DROP } ;
DIP 4 { DROP } ;
DUG 3 ;
DIP 3 { DUP } ;
DIG 3 ;
NIL operation ;
PAIR ;
DIP { DROP 10 } } ;
SWAP ;
APPLY ;
DIP { DIP { DIP { DIP { DIP { DIP { DUP } ; DUP ; DIP { PAIR } ; SWAP } ; SWAP } ;
SWAP } ;
SWAP } ;
SWAP } ;
SWAP ;
LAMBDA
(pair (pair address address)
(pair nat (pair (pair (pair address (big_map address nat)) (pair bool string)) nat)))
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat)
{ DUP ;
CAR ;
CAR ;
DIP { DUP } ;
SWAP ;
CAR ;
CDR ;
DIP 2 { DUP } ;
DIG 2 ;
CDR ;
CAR ;
DIP 3 { DUP } ;
DIG 3 ;
CDR ;
CDR ;
DUP ;
CAR ;
CAR ;
CDR ;
DIP 3 { DUP } ;
DIG 3 ;
DIP { DIP { DUP } ; SWAP ; CAR ; CAR ; CDR } ;
GET ;
DIP 5 { DUP } ;
DIG 5 ;
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CAR ; CDR } ;
GET ;
DUP ;
IF_NONE
{ PUSH string "[doTransfer] unknown owner" ; FAILWITH }
{ DUP ;
DIP { DIP 5 { DUP } ; DIG 5 } ;
COMPARE ;
GE ;
DUP ;
IF { DIP 8 { DUP } ;
DIG 8 ;
DIP { DIP { DUP } ;
SWAP ;
DIP { DIP 6 { DUP } ; DIG 6 } ;
SUB ;
ABS ;
SOME ;
DIP { DIP 5 { DUP } ; DIG 5 ; CAR ; CAR ; CDR } } ;
UPDATE ;
DIP { DIP 5 { DUP } ;
DIG 5 ;
DUP ;
CDR ;
SWAP ;
CAR ;
DUP ;
CDR ;
SWAP ;
CAR ;
CAR } ;
SWAP ;
PAIR ;
PAIR ;
PAIR ;
DIP 6 { DROP } ;
DUG 5 ;
DIP 3 { DUP } ;
DIG 3 ;
IF_NONE
{ DIP 7 { DUP } ;
DIG 7 ;
DIP { DIP 6 { DUP } ;
DIG 6 ;
SOME ;
DIP { DIP 5 { DUP } ; DIG 5 ; CAR ; CAR ; CDR } } ;
UPDATE ;
DIP { DIP 5 { DUP } ;
DIG 5 ;
DUP ;
CDR ;
SWAP ;
CAR ;
DUP ;
CDR ;
SWAP ;
CAR ;
CAR } ;
SWAP ;
PAIR ;
PAIR ;
PAIR ;
DIP 6 { DROP } ;
DUG 5 ;
PUSH unit Unit }
{ DIP 8 { DUP } ;
DIG 8 ;
DIP { DUP ;
DIP { DIP 7 { DUP } ; DIG 7 } ;
ADD ;
SOME ;
DIP { DIP 6 { DUP } ; DIG 6 ; CAR ; CAR ; CDR } } ;
UPDATE ;
DIP { DIP 6 { DUP } ;
DIG 6 ;
DUP ;
CDR ;
SWAP ;
CAR ;
DUP ;
CDR ;
SWAP ;
CAR ;
CAR } ;
SWAP ;
PAIR ;
PAIR ;
PAIR ;
DIP 7 { DROP } ;
DUG 6 ;
DROP ;
PUSH unit Unit } }
{ PUSH string "[doTransfer] not enough to burn" ; FAILWITH } ;
DIP { DROP 2 } } ;
DROP ;
DIP 3 { DUP } ;
DIG 3 ;
DIP { DROP 8 } } ;
DUP ;
DIP { PAIR } ;
SWAP ;
LAMBDA
(pair (pair (lambda
(pair (pair address address)
(pair nat (pair (pair (pair address (big_map address nat)) (pair bool string)) nat)))
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
(pair (lambda (pair (pair (pair address (big_map address nat)) (pair bool string)) nat) bool)
(lambda
(pair address (pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
bool)))
(pair (pair address address)
(pair nat (pair (pair (pair address (big_map address nat)) (pair bool string)) nat))))
(pair (list operation)
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
{ DUP ;
CAR ;
SWAP ;
CDR ;
DIP { DUP ; CDR ; SWAP ; CAR ; DIP { DUP ; CDR ; SWAP ; CAR } } ;
DUP ;
CAR ;
CAR ;
DIP { DUP } ;
SWAP ;
CAR ;
CDR ;
DIP 2 { DUP } ;
DIG 2 ;
CDR ;
CAR ;
DIP 3 { DUP } ;
DIG 3 ;
CDR ;
CDR ;
DUP ;
DIP { DIP 6 { DUP } ; DIG 6 } ;
EXEC ;
DUP ;
IF { PUSH string "[transfer] contract is paused" ; FAILWITH }
{ PUSH unit Unit } ;
DROP ;
DIP { DUP } ;
SWAP ;
SENDER ;
PAIR ;
DIP { DIP 8 { DUP } ; DIG 8 } ;
EXEC ;
DIP { DIP 4 { DUP } ; DIG 4 ; SENDER ; COMPARE ; EQ } ;
OR ;
DUP ;
IF { PUSH unit Unit }
{ PUSH string "[transfer] need admin privileges or must be the sender" ;
FAILWITH } ;
DROP ;
DIP 3 { DUP } ;
DIG 3 ;
PUSH nat 0 ;
SWAP ;
COMPARE ;
GT ;
DUP ;
IF { PUSH unit Unit }
{ PUSH string "[transfer] value must be positive" ; FAILWITH } ;
DROP ;
DIP 6 { DUP } ;
DIG 6 ;
DIP { DIP 5 { DUP } ; DIG 5 } ;
PAIR ;
DIP { DIP 4 { DUP } ; DIG 4 ; DIP { DIP 3 { DUP } ; DIG 3 } ; PAIR } ;
PAIR ;
DIP { DIP 8 { DUP } ; DIG 8 } ;
EXEC ;
DIP { DIP 3 { DUP } ; DIG 3 ; DROP } ;
DIP 4 { DROP } ;
DUG 3 ;
DIP 3 { DUP } ;
DIG 3 ;
NIL operation ;
PAIR ;
DIP { DROP 11 } } ;
SWAP ;
APPLY ;
DIP { DIP { DIP { DIP { DIP { DIP { DIP { DIP { DUP } ; SWAP } ; SWAP } ; SWAP } ;
SWAP } ;
SWAP } ;
SWAP } ;
SWAP } ;
SWAP ;
LAMBDA
(pair (lambda
(pair address (pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
bool)
(pair bool (pair (pair (pair address (big_map address nat)) (pair bool string)) nat)))
(pair (list operation)
(pair (pair (pair address (big_map address nat)) (pair bool string)) nat))
{ DUP ;
CAR ;
SWAP ;
CDR ;
DUP ;
CAR ;
DIP { DUP } ;
SWAP ;
CDR ;
DUP ;
SENDER ;
PAIR ;
DIP { DIP 3 { DUP } ; DIG 3 } ;
EXEC ;
DUP ;
IF { DIP 2 { DUP } ;
DIG 2 ;
DIP { DIP { DUP } ;
SWAP ;
DUP ;
CDR ;
SWAP ;
CAR ;
DUP ;
CAR ;
SWAP ;
CDR ;
CDR } ;
PAIR ;
SWAP ;
PAIR ;
PAIR ;
SWAP ;
DIP { DIP { DROP } } ;
PUSH unit Unit }
{ PUSH string "[pause] need admin privileges" ; FAILWITH } ;
DROP ;
DIP { DUP } ;
SWAP ;
NIL operation ;
PAIR ;
DIP { DROP 5 } } ;
SWAP ;
APPLY ;
DIP 10 { DUP } ;
DIG 10 ;
CAR ;
DIP 11 { DUP } ;
DIG 11 ;
CDR ;
DIP { DUP } ;
SWAP ;
IF_LEFT
{ DUP ;
IF_LEFT
{ DUP ;
IF_LEFT
{ DUP ;
DUP ;
CDR ;
DIP { DUP ; CAR } ;
PAIR ;
DIP { DIP 4 { DUP } ; DIG 4 } ;
PAIR ;
DIP { DIP 9 { DUP } ; DIG 9 } ;
EXEC ;
DIP { DROP 2 } }
{ DUP ;
DUP ;
CAR ;
DIP { DUP ; CDR } ;
PAIR ;
DIP { DIP 4 { DUP } ; DIG 4 } ;
PAIR ;
DIP { DIP 11 { DUP } ; DIG 11 } ;
EXEC ;
DIP { DROP 2 } } ;
DIP { DROP } }
{ DUP ;
IF_LEFT
{ DUP ;
DUP ;
DIP { DIP 4 { DUP } ; DIG 4 } ;
PAIR ;
DIP { DIP 6 { DUP } ; DIG 6 } ;
EXEC ;
DIP { DROP 2 } }
{ DUP ;
DUP ;
DIP { DIP 4 { DUP } ; DIG 4 } ;
PAIR ;
DIP { DIP 13 { DUP } ; DIG 13 } ;
EXEC ;
DIP { DROP 2 } } ;
DIP { DROP } } ;
DIP { DROP } }
{ DUP ;
DUP ;
CAR ;
CAR ;
DIP { DUP ; CAR ; CDR } ;
PAIR ;
DIP { DUP ; CDR ; DIP { DIP 2 { DUP } ; DIG 2 } ; PAIR } ;
PAIR ;
DIP { DIP 5 { DUP } ; DIG 5 } ;
EXEC ;
DIP { DROP 2 } } ;
DIP { DROP 13 } } }
Hi all,
What does this error look like to you ?
For me it seems to mean that it doesn't want to deploy a contract because the balance is of only 49 tz and it's asking for 1276 tz ... But that seems a lot, the same contract used to pass with just a few tz ...
Am I doing something wrong ? Does this make sense to you ?
Thank you
bson.loads(bytes.fromhex(mainnet.blocks[1].header()['content']['protocol_parameters'])[4:])
p = MichelsonParser()
p.parse('(Pair 1 2)') # fails
p.parse('Pair 1 2') # ok
It seems as if this library requires a secret keys file.
I want to run this on an AWS lambda, which cannot access the home directory. And state is not reliably persisted.
Is there some way of supplying the secret key as an argument or environment variable instead?
Hello,
I wrote a simple counter smart contract in Michelson :
# This contract contains an integer in the storage (= a counter).
# It has two entrypoints :
# increaseCounterBy : storage = storage - value
# decreaseCounterBy : storage = storage - value
parameter (or (int %increaseCounterBy) (int %decreaseCounterBy));
storage int;
code {
UNPAIR;
IF_LEFT { ADD }
{
SWAP;
SUB
};
NIL operation;
PAIR;
FAIL
}
And I wrote simple tests :
from os.path import dirname, join
from unittest import TestCase
from pytezos import ContractInterface
class CounterContractTest(TestCase):
@classmethod
def setUpClass(cls):
contract_path = join(dirname(dirname(__file__)), "contracts/counter.tz")
cls.contract = ContractInterface.create_from(contract_path)
def test_increaseCounterBy_should_increase_counter_in_storage_by_increase_value(self):
# Given
increase_value = 5
# When
result = self.contract.increaseCounterBy(increase_value).result(storage=0)
# Then
self.assertEqual(result.storage, 5)
def test_decreaseCounterBy_should_decrease_counter_in_storage_by_decrease_value(self):
# Given
decrease_value = 5
# When
result = self.contract.decreaseCounterBy(decrease_value).result(storage=0)
# Then
self.assertEqual(result.storage, -5)
But when running the tests, I have this error :
Version used : pytezos-2.1.3.
Merge into resulting storage together with the passed data (bcd-like)
Sample case #44
DUP n
Hi, we would like to use pytezos as a module without waiting for releases in order to get the latest version, could you add the steps in order to achieve that ?
Thank you very much,
Loup
eg.
contract (SmartPy):
class Repeater(sp.Contract):
def __init__(self):
self.init(storage=0)
@sp.entryPoint
def repeat(self, params):
self.data.storage = params
contract (Michelson):
parameter int;
storage int;
code
{
DUP; # pair(params, storage).pair(params, storage)
CDR; # storage.pair(params, storage)
SWAP; # pair(params, storage).storage
CAR; # params.storage
# Entry point: repeat # params.storage
# self.data.storage = params # params.storage
SWAP; # storage.params
DROP; # params
NIL operation; # list operation.params
PAIR; # pair(_, params)
} # pair(_, params)
test:
def test_calling_repeater_with_amount_returns_operation():
"""Should return operation list."""
instance = ContractInterface.create_from('repeater.tz')
result = instance \
.call(7) \
.with_amount(Decimal('1')) \
.result(storage=0, sender='tz1W4W2yFAHz7iGyQvFys4K7Df9mZL6cSKCp')
assert len(result.operations) > 0
pytezos version 2.4.2
raceback (most recent call last):
File "/Users/eugenemishura/mschema/multi_asset/tezos_mac_tests/test_pairs.py", line 1296, in test_pairs
ci.contract.storage
File "*/.venv/lib/python3.7/site-packages/pytezos/michelson/contract.py", line 292, in storage
return ContractStorage(self.code[1])
File "*/.venv/lib/python3.7/site-packages/pytezos/michelson/contract.py", line 115, in __init__
self.__doc__ = generate_docstring(self.schema, "storage")
File "*/.venv/lib/python3.7/site-packages/pytezos/michelson/docstring.py", line 118, in generate_docstring
docstring.append(f'${prim}:\n\t{domain_types[prim]}\n')
KeyError: 'pair'
Also not allowed on options (entrypoint), see vesting contract migration
See https://tezos.gitlab.io/whitedoc/michelson.html#annotations
Ensure full type coverage
Implement 'or' branch matching
Support enums and skippping 'unit'
Expand macros while parsing to Micheline
Traceback (most recent call last):
File "/home/mickey/.pyenv/versions/3.7.0/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell
yield gen.maybe_future(handler(stream, idents, msg))
File "/home/mickey/.pyenv/versions/3.7.0/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/home/mickey/.pyenv/versions/3.7.0/lib/python3.7/site-packages/tornado/gen.py", line 209, in wrapper
yielded = next(result)
File "/home/mickey/.pyenv/versions/3.7.0/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 541, in execute_request
user_expressions, allow_stdin,
File "/home/mickey/.local/lib/python3.7/site-packages/michelson_kernel/kernel.py", line 88, in do_execute
int_res = self.interpreter.execute(code)
File "/home/mickey/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pytezos/repl/interpreter.py", line 177, in execute
int_res['result'] = format_result(res)
File "/home/mickey/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pytezos/repl/interpreter.py", line 129, in format_result
return {'value': list(map(format_stack_item, result['stack'])), **result}
File "/home/mickey/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pytezos/repl/interpreter.py", line 26, in format_stack_item
row['value'] = yaml.dump([get_content(x) for x in item.val_expr]).rstrip('\n')
File "/home/mickey/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pytezos/repl/interpreter.py", line 26, in <listcomp>
row['value'] = yaml.dump([get_content(x) for x in item.val_expr]).rstrip('\n')
File "/home/mickey/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pytezos/repl/interpreter.py", line 15, in get_content
content = item.val_expr.get('_content')
AttributeError: 'dict' object has no attribute 'val_expr'
Hello,
By using SmartPy, I wrote this simple Smart Contract with one storage containing a pair of address and string :
import smartpy as sp
class ComplexStorage(sp.Contract):
"""
ownerAddress : address
name : string
"""
def __init__(self, ownerAddress, name):
self.init(ownerAddress=ownerAddress, name=name)
@sp.entryPoint
def set_name(self, name):
self.data.name = name
Then I compiled it into Michelson using SmartPy CLI :
parameter string ;
storage (pair (string %name) (address %ownerAddress)) ;
code { DUP ;
DUP ;
CDR ;
SWAP ;
CAR ;
SWAP ;
CDR ;
SWAP ;
PAIR ;
SWAP ;
DROP ;
NIL operation ;
PAIR }
And then this related test :
from os.path import dirname, join
from unittest import TestCase
from pytezos import ContractInterface, MichelsonRuntimeError
project_dir = dirname(dirname(__file__))
class ComplexStorageContractTest(TestCase):
@classmethod
def setUpClass(cls):
cls.complexStorage = ContractInterface.create_from(join(project_dir, 'src/complexStorageCode.tz'), shell='sandboxnet')
def test_set_name(self):
res = self.complexStorage.call("newName")
res.result(storage=['name', 'tz1YQTmJxey1qR9xD49V9eVmqgJ6DdcBPDyY'])
# self.assertEqual(..., res.storage)
But the test fails with a pytezos.michelson.converter.MichelineSchemaError
error because the line res.result(storage=['name', 'tz1YQTmJxey1qR9xD49V9eVmqgJ6DdcBPDyY'])
seems to be incorrect :
I am using pytezos-2.0.8.
Disable traceback
Do not show micheline source (pro: convert location to a line in Michelson source + failed code+-5 instructions)
the latest ligo, is wrapping Michelson in braces during compilation
eg.
docker run --user=`id -u` -v $PWD:$PWD -w $PWD ligolang/ligo:next compile-contract {ligo file path} main
outputs:
{
parameter unit;
storage int;
code ...
which is not working with PyTezos eg.
ContractInterface.create_from(contract_output_path)
apparently this format (with the braces is valid Michelson, ie type checker says it's fine:
tezos-client typecheck script <path to tz file with braces>
outputs:
Well typed
I've tried this
import pytezos
print(pytezos.Key('edesk...', passphrase='yourpassword').secret_key())
but get:
TypeError: init() got an unexpected keyword argument 'passphrase'
Hello !
Getting a new KeyError with 2.5.0:
djblockchain/tezos.py:140: in get_client
operation = client.reveal().autofill().sign().inject()
/usr/lib/python3.8/site-packages/pytezos/tools/docstring.py:67: in __call__
return method(self.class_instance, *args, **kwargs)
/usr/lib/python3.8/site-packages/pytezos/operation/group.py:167: in autofill
opg = self.fill()
/usr/lib/python3.8/site-packages/pytezos/tools/docstring.py:67: in __call__
return method(self.class_instance, *args, **kwargs)
/usr/lib/python3.8/site-packages/pytezos/operation/group.py:122: in fill
contents=list(map(fill_content, self.contents)),
/usr/lib/python3.8/site-packages/pytezos/operation/group.py:118: in fill_content
content[k] = v(content) if callable(v) else v
/usr/lib/python3.8/site-packages/pytezos/operation/group.py:109: in <lambda>
'fee': lambda x: str(default_fee(x)),
/usr/lib/python3.8/site-packages/pytezos/operation/fees.py:32: in default_fee
consumed_gas=default_gas_limit(content),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
content = {'counter': '1', 'fee': '0', 'gas_limit': '0', 'kind': 'reveal', ...}
def default_gas_limit(content) -> int:
""" Get default gas limit by operation kind.
:param content: operation content {..., "kind": "transaction", ... }
"""
values = {
'reveal': 10000,
'delegation': 10000,
'origination': hard_gas_limit_per_operation if content.get('script') else 10000,
> 'transaction': hard_gas_limit_per_operation if content['destination'].startswith('KT') else 10207
}
E KeyError: 'destination'
/usr/lib/python3.8/site-packages/pytezos/operation/fees.py:46: KeyError
No problem with <2.5.0
We've got some parse errors with pytezos but our code works fine with tezos-client:
ipdb> Contract.from_micheline('smart-contracts/nyx/IssuingEntity.json').script()
*** pytezos.michelson.converter.MichelineSchemaError: Failed to build schema
ipdb> Contract.from_michelson('smart-contracts/nyx/IssuingEntity.tz').script()
*** pytezos.michelson.grammar.MichelsonParserError: LexToken(/,'/',1,0)
ipdb> Contract.from_file('smart-contracts/nyx/IssuingEntity.tz').script()
*** ValueError: Cannot create default value for `address` at `0110`
As such, calling originate(script=Contract.script())
isn't doing the trick for us (we need demo tomorrow ...).
Is there any way to originate a contract from pytezos without going through any parsing by pytezos itself ? We have our storage and all arguments ready in michelson.
Leave only necessary rpc wrapping functional
Focus on operation injection and code tracing
Move misc functional in separate modules
Fix examples
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.