Skip to content

Instantly share code, notes, and snippets.

@ponimas
Created May 7, 2018 09:28
Show Gist options
  • Save ponimas/4bb48ea0bae34de79b75e13b618dc57e to your computer and use it in GitHub Desktop.
Save ponimas/4bb48ea0bae34de79b75e13b618dc57e to your computer and use it in GitHub Desktop.
import exonum.transactions as tx
import exonum.datatypes as exonum
transactions = tx.transactions(service_id=128)
@transactions
class Create(metaclass=exonum.EncodingStruct):
data_hash = exonum.Hash
author_name = exonum.Str
author_birthday = exonum.DateTime
author_birthplace = exonum.Str
created_at = exonum.DateTime
was_published = exonum.bool
place_of_origin = exonum.Str
name = exonum.Str
details = exonum.Str
def main():
# from pysodium import crypto_sign_keypair
import json
# use nanotime if you need nanoseconds resolution
# from datetime import datetime
secret_key = bytes.fromhex(
"5520c351b7760aedeef32687918eb2587ab515e4ae0eeef271"
"a0f0a99f1df3710f17189c062e7f3fbb47a21834d41e4d5c53"
"88dd7db38c4de1ce732971a38ef9")
tx = (Create(
**{
"author_birthday": {
"nanos": 696916964,
"secs": "1525683304"
},
"author_birthplace": "dumpster",
"author_name": "name",
# "created_at" datetime.now():
"created_at": {
"nanos": 696922154,
"secs": "1525683304"
},
"data_hash": bytes.fromhex("37ec65607daf31e1ec0edd1a18ab8555425320e09e09d97aee0609f3df52fdc3"),
"details": "dunno",
"name": "test name",
"place_of_origin": "dumpster2",
"was_published": True
})
.tx(secret_key=secret_key))
print(json.dumps(tx, indent=2))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment