Skip to content

Commit

Permalink
fix some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ackness committed Feb 9, 2023
1 parent 5486cd6 commit 398a7a6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ dmypy.json
.xml
examples/test*
aptc/test*
temp_*.py
4 changes: 2 additions & 2 deletions aptc/libs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ def get_account_transactions(self, address) -> dict:
def submit_transaction(self, txn_dict: Dict):
return self.provider.post(
APTTransactionsAPI.SUBMIT_TRANSACTION, params_dict=txn_dict,
headers=self.provider.DEFAULT_HEADERS
# headers=self.provider.DEFAULT_HEADERS
)

submit = submit_transaction

def submit_batch_transactions(self, batch_txn_dict: Dict):
return self.provider.post(
APTTransactionsAPI.SUBMIT_BATCH_TRANSACTIONS, params_dict=batch_txn_dict,
headers=self.provider.DEFAULT_HEADERS
# headers=self.provider.DEFAULT_HEADERS
)

submit_batch = submit_batch_transactions
Expand Down
43 changes: 43 additions & 0 deletions examples/example2-send-batch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import time

from loguru import logger

from aptc import Account, APT, new_client
from aptc.libs import build_transfer_payload

# init logger
logger.add("example2.log")

client = new_client()

# submit transaction
# load your private key
account = Account.load_key(os.environ['private_key'])
account_address = account.address()
receiver_address = "0x8d763223180a2b92f97755a3ea581f1c68d342275ca6118badff663f57aca7a5"

payload_1 = build_transfer_payload(receiver_address, int(0.1 * APT))
payload_2 = build_transfer_payload(receiver_address, int(0.2 * APT))

txn_dict = {
"sender": f"{account_address}",
"sequence_number": str(client.get_account_sequence_number(account_address)),
"max_gas_amount": str(100_000),
"gas_unit_price": str(100),
"expiration_timestamp_secs": str(int(time.time()) + 100),
"payload": [payload_1, payload_2],
}
# encode this transaction
encoded = client.encode(txn_dict)
# sign this transaction
signature = account.sign(encoded)

txn_dict["signature"] = {
"type": "ed25519_signature",
"public_key": f"{account.public_key()}",
"signature": f"{signature}",
}

# submit transaction
tx = client.submit_transaction(txn_dict)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setup(
name='aptc',
packages=find_packages(),
version='0.0.2',
version='0.0.3',
license='MIT',
description='A simple web3py like client for APTOS chain.',
long_description=long_description,
Expand Down

0 comments on commit 398a7a6

Please sign in to comment.