-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sending Transactions - working only once for newly created accounts #12
Comments
Looking for #9, I think It may help you. :) |
Thanks @HubCodes However - the issue with the transfers appears to still be happening.. Were you able to resolve it somehow? |
@jnsead Umm... I used following python code to know how libra api works. I hope it can help you. from pylibra import LibraClient, LibraWallet
from pylibra.proto.transaction_pb2 import TransactionArgument
from pylibra.transaction import CustomTransaction, TransferTransaction
from pylibra.proto.admission_control_pb2 import SubmitTransactionRequest
from pylibra.proto.transaction_pb2 import SignedTransaction
from pylibra.proto.transaction_pb2 import RawTransaction
from sha3 import sha3_256
import time
tx_script = '4c49425241564d0a010007014a00000004000000034e000000060000000c54000000060000000d5a0000000600000005600000002900000004890000002000000007a90000000e00000000000001000200010300020002040200030003020402063c53454c463e0c4c696272614163636f756e74046d61696e0f7061795f66726f6d5f73656e64657200000000000000000000000000000000000000000000000000000000000000000001020104000c000c0111010002'
wallet = LibraWallet()
account1 = wallet.get_account(1)
account2 = wallet.get_account(2)
client = LibraClient()
client.mint_with_faucet(account1, 10000000)
print(f'Account1 address: {account1.address}')
print(f'Account1 private key: {account1.private_key}')
print(f'Account2 address: {account2.address}')
print(f'Account2 private key: {account2.private_key}')
address1 = account1.address
address2 = account2.address
sequence_number = 0 # FIXME: Change it repeatedly
raw_tx = RawTransaction()
raw_tx.sender_account = bytes.fromhex(address1)
raw_tx.sequence_number = sequence_number
raw_tx.max_gas_amount = 100000
raw_tx.gas_unit_price = 1
raw_tx.expiration_time = int(time.time()) + 10
raw_tx.program.code = bytes.fromhex(tx_script)
arg1 = raw_tx.program.arguments.add()
arg1.type = TransactionArgument.ADDRESS
arg1.data = bytes.fromhex(address2)
arg2 = raw_tx.program.arguments.add()
arg2.type = TransactionArgument.U64
arg2.data = (1000).to_bytes(8, 'little') # Send 0.001 lib
tx = raw_tx.SerializeToString()
request = SubmitTransactionRequest()
signed_tx = request.signed_txn
signed_tx.raw_txn_bytes = tx
signed_tx.sender_public_key = bytes.fromhex(account1.public_key)
hashfn = sha3_256()
hashfn.update(
bytes.fromhex('46f174df6ca8de5ad29745f91584bb913e7df8dd162e3e921a5c1d8637c88d16'))
hashfn.update(tx)
signature = account1.sign(hashfn.digest())[:64]
signed_tx.sender_signature = signature
result = client.stub.SubmitTransaction(request)
print(result) And I found Its result in libexplorer: https://libexplorer.com/version/14103 |
Thanks for that! I have a question please... Also could you please explain a bit more about the |
@jnsead (1) Actually, If you have a private key, you can send transactions without regard to a wallet. |
@HubCodes I ran your code and get the result as below, Could you please check it out? |
@sabgkang |
@HubCodes Thank you for the prompt reply. Indeed, Libra evolves too fast. |
Sorry guys we have been very busy with Band Protocol IEO launch. I will get back on all these issues asap. |
Hi @HubCodes - just wondering - is the above snippet you posted in #12 (comment) still working for you? If not, do you or anyone else know what's changed? I'm trying to figure out how and what needs updating but running into a few issues |
@jnsead |
Thanks for the reply @HubCodes |
@sorawit - do you have any ideas on this? It appears there have been changes earlier this month (https://community.libra.org/t/testnet-update-september-4th/1630). I'm not familiar with Rust - was wondering if you'd be able to help out? |
I'm running into strange behaviour with transactions. Seems like I can create a transaction for newly created accounts but then I can't send any further transactions afterwards, regardless of whether the first transaction was successfull or not. As far as I can tell, I am following the steps documented in the readme.
Does anyone know what could possibly be causing this?
The text was updated successfully, but these errors were encountered: