diff --git a/pyband/msg scripts/MsgCreateDataSource.py b/pyband/msg scripts/MsgCreateDataSource.py new file mode 100644 index 0000000..bde4f45 --- /dev/null +++ b/pyband/msg scripts/MsgCreateDataSource.py @@ -0,0 +1,64 @@ +import os + +from pyband.client import Client +from pyband.transaction import Transaction +from pyband.wallet import PrivateKey + +from pyband.proto.cosmos.base.v1beta1.coin_pb2 import Coin +from pyband.proto.oracle.v1.tx_pb2 import MsgCreateDataSource +from google.protobuf.json_format import MessageToJson + +def main(): + # Step 1 + #Choose GRPC + #Laozi Mainnet: laozi1.bandchain.org + #Laozi Testnet: laozi-testnet4.bandchain.org + grpc_url = "laozi1.bandchain.org" + c = Client(grpc_url) + + # Step 2 + #DO NOT SHARE YOUR mnemonic!!! + private_key = PrivateKey.from_mnemonic("Enter your mnemonic (Seed Phrases)") + public_key = private_key.to_public_key() + sender_addr = public_key.to_address() + sender = sender_addr.to_acc_bech32() + + # Step 3 + send_msg = MsgCreateDataSource( + sender=sender, + owner = "Band Address of the Owner", + treasury = "Band Address of the Treasury", + name = "Name of the Data Source", + description = "Description of the Data Source", + fee = [Coin(amount="Fee per single request", denom="uband")], #1000000 Uband is one Band + executable = b' Paste your Code (Executable) in here \n', #the b'\n' converts your code into []Byte + ) + + account = c.get_account(sender) + account_num = account.account_number + sequence = account.sequence + + chain_id = c.get_chain_id() + + # Step 4 + txn = ( + Transaction() + .with_messages(send_msg) + .with_sequence(sequence) + .with_account_num(account_num) + .with_chain_id(chain_id) + .with_gas(2000000) + .with_memo("") + ) + + # Step 5 + sign_doc = txn.get_sign_doc(public_key) + signature = private_key.sign(sign_doc.SerializeToString()) + tx_raw_bytes = txn.get_tx_data(signature, public_key) + + # Step 6 + tx_block = c.send_tx_block_mode(tx_raw_bytes) + print(MessageToJson(tx_block)) + +if __name__ == "__main__": + main() diff --git a/pyband/msg scripts/MsgCreateOracleScript.py b/pyband/msg scripts/MsgCreateOracleScript.py new file mode 100644 index 0000000..b82e153 --- /dev/null +++ b/pyband/msg scripts/MsgCreateOracleScript.py @@ -0,0 +1,63 @@ +import os + +from pyband.client import Client +from pyband.transaction import Transaction +from pyband.wallet import PrivateKey + +from pyband.proto.oracle.v1.tx_pb2 import MsgCreateOracleScript +from google.protobuf.json_format import MessageToJson + +def main(): + # Step 1 + #Choose GRPC + #Laozi Mainnet: laozi1.bandchain.org + #Laozi Testnet: laozi-testnet4.bandchain.org + grpc_url = "laozi-testnet4.bandchain.org" + c = Client(grpc_url) + + # Step 2 + #DO NOT SHARE YOUR mnemonic!!! + private_key = PrivateKey.from_mnemonic("Enter your mnemonic (Seed Phrases)") + public_key = private_key.to_public_key() + sender_addr = public_key.to_address() + sender = sender_addr.to_acc_bech32() + + # Step 3 + send_msg = MsgCreateOracleScript( + sender=sender, + owner = "Band Address of the Owner", + name = "Name of the Oracle Script", + description = "Description of the Oracle Script", + code = b' The Owasm-compiled binary attached to this Oracle Script \n', #the b'\n' converts your code into Byte + schema= "The schema detailing the inputs and outputs of this Oracle Script, as well as the corresponding types", + source_code_url="Url of the Source Code", + ) + + account = c.get_account(sender) + account_num = account.account_number + sequence = account.sequence + + chain_id = c.get_chain_id() + + # Step 4 + txn = ( + Transaction() + .with_messages(send_msg) + .with_sequence(sequence) + .with_account_num(account_num) + .with_chain_id(chain_id) + .with_gas(2000000) + .with_memo("") + ) + + # Step 5 + sign_doc = txn.get_sign_doc(public_key) + signature = private_key.sign(sign_doc.SerializeToString()) + tx_raw_bytes = txn.get_tx_data(signature, public_key) + + # Step 6 + tx_block = c.send_tx_block_mode(tx_raw_bytes) + print(MessageToJson(tx_block)) + +if __name__ == "__main__": + main() diff --git a/pyband/msg scripts/MsgEditDataSource.py b/pyband/msg scripts/MsgEditDataSource.py new file mode 100644 index 0000000..27f7642 --- /dev/null +++ b/pyband/msg scripts/MsgEditDataSource.py @@ -0,0 +1,68 @@ +import os + +from pyband.client import Client +from pyband.transaction import Transaction +from pyband.wallet import PrivateKey + +from pyband.proto.cosmos.base.v1beta1.coin_pb2 import Coin +from pyband.proto.oracle.v1.tx_pb2 import MsgEditDataSource +from google.protobuf.json_format import MessageToJson + +def main(): + # Step 1 + #Choose GRPC + #Laozi Mainnet: laozi1.bandchain.org + #Laozi Testnet: laozi-testnet4.bandchain.org + grpc_url = "laozi-testnet4.bandchain.org" + c = Client(grpc_url) + + # Step 2 + #DO NOT SHARE YOUR mnemonic!!! + private_key = PrivateKey.from_mnemonic("Enter your mnemonic (Seed Phrases)") + public_key = private_key.to_public_key() + sender_addr = public_key.to_address() + sender = sender_addr.to_acc_bech32() + + # Step 3 + send_msg = MsgEditDataSource( + data_source_id="Data Source ID from your existing Data Source without Quotation Marks (int)", + sender=sender, + #now you can change your existingData Source completely + owner = "Band Address of the Owner", + treasury = "Band Address of the Treasury", + name = "Name of the Data Source", + description = "Description of the Data Source", + fee = [Coin(amount="Fee per single request", denom="uband")], #1000000 Uband is one Band + executable = b' Paste your Code (Executable) in here \n', #the b'\n' converts your code into Byte + ) + + account = c.get_account(sender) + account_num = account.account_number + sequence = account.sequence + + fee = [Coin(amount="10000", denom="uband")] + chain_id = c.get_chain_id() + + # Step 4 + txn = ( + Transaction() + .with_messages(send_msg) + .with_sequence(sequence) + .with_account_num(account_num) + .with_chain_id(chain_id) + .with_gas(2000000) + .with_fee(fee) + .with_memo("") + ) + + # Step 5 + sign_doc = txn.get_sign_doc(public_key) + signature = private_key.sign(sign_doc.SerializeToString()) + tx_raw_bytes = txn.get_tx_data(signature, public_key) + + # Step 6 + tx_block = c.send_tx_block_mode(tx_raw_bytes) + print(MessageToJson(tx_block)) + +if __name__ == "__main__": + main() diff --git a/pyband/msg scripts/MsgEditOracleScript.py b/pyband/msg scripts/MsgEditOracleScript.py new file mode 100644 index 0000000..11ae7ce --- /dev/null +++ b/pyband/msg scripts/MsgEditOracleScript.py @@ -0,0 +1,64 @@ +import os + +from pyband.client import Client +from pyband.transaction import Transaction +from pyband.wallet import PrivateKey + +from pyband.proto.oracle.v1.tx_pb2 import MsgEditOracleScript +from google.protobuf.json_format import MessageToJson + +def main(): + # Step 1 + #Choose GRPC + #Laozi Mainnet: laozi1.bandchain.org + #Laozi Testnet: laozi-testnet4.bandchain.org + grpc_url = "laozi-testnet4.bandchain.org" + c = Client(grpc_url) + + # Step 2 + #DO NOT SHARE YOUR mnemonic!!! + private_key = PrivateKey.from_mnemonic("Enter your mnemonic (Seed Phrases)") + public_key = private_key.to_public_key() + sender_addr = public_key.to_address() + sender = sender_addr.to_acc_bech32() + + # Step 3 + send_msg = MsgEditOracleScript( + oracle_script_id="Oracle Script ID from your existing Data Source without Quotation Marks (int)", + sender=sender, + owner = "Band Address of the Owner", + name = "Name of the Oracle Script", + description = "Description of the Oracle Script", + code = b' The Owasm-compiled binary attached to this Oracle Script \n', #the b'\n' converts your code into Byte + schema= "The schema detailing the inputs and outputs of this Oracle Script, as well as the corresponding types", + source_code_url="Url of the Source Code", + ) + + account = c.get_account(sender) + account_num = account.account_number + sequence = account.sequence + + chain_id = c.get_chain_id() + + # Step 4 + txn = ( + Transaction() + .with_messages(send_msg) + .with_sequence(sequence) + .with_account_num(account_num) + .with_chain_id(chain_id) + .with_gas(2000000) + .with_memo("") + ) + + # Step 5 + sign_doc = txn.get_sign_doc(public_key) + signature = private_key.sign(sign_doc.SerializeToString()) + tx_raw_bytes = txn.get_tx_data(signature, public_key) + + # Step 6 + tx_block = c.send_tx_block_mode(tx_raw_bytes) + print(MessageToJson(tx_block)) + +if __name__ == "__main__": + main() diff --git a/pyband/msg scripts/MsgRequestData.py b/pyband/msg scripts/MsgRequestData.py new file mode 100644 index 0000000..cdba954 --- /dev/null +++ b/pyband/msg scripts/MsgRequestData.py @@ -0,0 +1,65 @@ +import os + +from pyband.client import Client +from pyband.transaction import Transaction +from pyband.wallet import PrivateKey + +from pyband.proto.cosmos.base.v1beta1.coin_pb2 import Coin +from pyband.proto.oracle.v1.tx_pb2 import MsgRequestData +from google.protobuf.json_format import MessageToJson + +def main(): + # Step 1 + #Choose GRPC + #Laozi Mainnet: laozi1.bandchain.org + #Laozi Testnet: laozi-testnet4.bandchain.org + grpc_url = "laozi-testnet4.bandchain.org" + c = Client(grpc_url) + + # Step 2 + #DO NOT SHARE YOUR mnemonic!!! + private_key = PrivateKey.from_mnemonic("Enter your mnemonic (Seed Phrases)") + public_key = private_key.to_public_key() + sender_addr = public_key.to_address() + sender = sender_addr.to_acc_bech32() + + # Step 3 + send_msg = MsgRequestData( + oracle_script_id = "Oracle Script ID from any existing Oracle you wish to get Data from without Quotation Marks (int)", + sender = sender, + calldata = "The data passed over to the oracle script for the script to use during its execution (string)", + ask_count = "Number of validators requested to answer the request without Quotation Marks (int)", + min_count = "The minimum number of validators necessary for the request to proceed to the execution phase without Quotation Marks (int)", + client_id = "The unique identifier of this oracle request, as specified by the client. This same unique ID will be sent back to the requester with the oracle response (string)", + ) + + account = c.get_account(sender) + account_num = account.account_number + sequence = account.sequence + + fee = [Coin(amount="10000", denom="uband")] + chain_id = c.get_chain_id() + + # Step 4 + txn = ( + Transaction() + .with_messages(send_msg) + .with_sequence(sequence) + .with_account_num(account_num) + .with_chain_id(chain_id) + .with_gas(2000000) + .with_fee(fee) + .with_memo("") + ) + + # Step 5 + sign_doc = txn.get_sign_doc(public_key) + signature = private_key.sign(sign_doc.SerializeToString()) + tx_raw_bytes = txn.get_tx_data(signature, public_key) + + # Step 6 + tx_block = c.send_tx_block_mode(tx_raw_bytes) + print(MessageToJson(tx_block)) + +if __name__ == "__main__": + main() diff --git a/pyband/msg scripts/README.md b/pyband/msg scripts/README.md new file mode 100644 index 0000000..4565e89 --- /dev/null +++ b/pyband/msg scripts/README.md @@ -0,0 +1,17 @@ +Band Protocol pyband Msg Scripts + +1. MsgRequestData.py to Request Data + +2. MsgCreateDataSource.py to create a new Data Source +3. MsgEditDataSource.py to edit an existing Data Source + +4. MsgCreateOracleScript.py to create a new Oracle Script +5. MsgEditOracleScript.py to edit an existing Oracle Script + + + +If you have any questions: + +https://docs.bandchain.org/ + +https://docs.bandchain.org/whitepaper/protocol-messages.html \ No newline at end of file