Created
June 7, 2019 23:12
-
-
Save StuartFarmer/f0b08f7e33be328686aa92dc4088229c to your computer and use it in GitHub Desktop.
Push Lamden TX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cilantro_ee.messages.transaction.publish import * | |
from cilantro_ee.messages.transaction.container import TransactionContainer | |
from cilantro_ee.messages.transaction.contract import ContractTransaction | |
from cilantro_ee.protocol import wallet | |
import requests | |
import secrets | |
SK = '' | |
SK = bytes.fromhex(SK) | |
KEY = wallet.new(seed=SK) | |
SK_KEY = KEY[0] | |
VK_KEY = KEY[1] | |
print(VK_KEY) | |
SERVER = 'http://134.209.163.189:8080/' | |
def make_transaction(contract, function, sk=SK_KEY, vk=VK_KEY, stamps=500000, kwargs={}): | |
tx = ContractTransaction.create(contract_name=contract, | |
func_name=function, | |
sender_sk=sk, | |
nonce=vk+secrets.token_hex(32), | |
stamps_supplied=stamps, | |
kwargs=kwargs) | |
container = TransactionContainer.create(tx) | |
return container.serialize() | |
def submit_transaction(tx, server=SERVER): | |
return requests.post(server, data=tx, verify=False) | |
tx = make_transaction('currency', 'transfer', kwargs={'to': 'tejas', 'amount': 100}, stamps=500000) | |
res = submit_transaction(tx) | |
print(res.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment