Example #1
0
def send_action(action_name, args):
    eos_conn = EosClient(api_endpoint="http://fabius.ciceron.xyz:8888", wallet_endpoint="http://fabius.ciceron.xyz:8888")
    txBuilder = TransactionBuilder(eos_conn)

    try:
        eos_conn.wallet_unlock(EOS['wallet'])
    except:
        pass

    # param = {
    #     "action": "writeaction",
    #     "code": "david",
    #     "args": {
    #         "user": "******",
    #         "action_type": action_name,
    #         "objective": "",
    #         "amount": point_amount
    #     }
    # }
    try:
        bin_param = eos_conn.chain_abi_json_to_bin(args)
        act = Action("blockiosk", action_name, "blockiosk", "active", bin_param['binargs'])
        ready_tx, chain_id =  txBuilder.build_sign_transaction_request([act])
        signed_transaction = eos_conn.wallet_sign_transaction(ready_tx, ['EOS7vtZvYDke1PVemFjAbnoEBmQCSkUtYg2CznRajsUdEP2r7pk7r'], chain_id)
        ret = eos_conn.chain_push_transaction(signed_transaction)
        return ret
    except:
#traceback.print_exc()
        return
Example #2
0
def send_action(action_name, args):
    eos_conn = EosClient(api_endpoint="http://localhost:8888",
                         wallet_endpoint="http://localhost:8888")
    txBuilder = TransactionBuilder(eos_conn)

    try:
        eos_conn.wallet_unlock(
            'PW5K79yJYFyWUdwgCQP9xa7ru4bEcFa2RuttMo5hJLinmMez69S3e')
    except:
        pass

    #param = {
    #          "action": "writeaction",
    #          "code": "david",
    #          "args": {
    #              "user": "******",
    #              "action_type": action_name,
    #              "objective": "",
    #              "amount": point_amount
    #          }
    #        }

    bin_param = eos_conn.chain_abi_json_to_bin(args)
    act = Action("david", action_name, "david", "active", bin_param['binargs'])
    ready_tx, chain_id = txBuilder.build_sign_transaction_request([act])
    signed_transaction = eos_conn.wallet_sign_transaction(
        ready_tx, ['EOS8KYhBt3w9yZ7dhNTPqHfDG4GgYKRfVGFoiKEcZ9byHNYhLcVPS'],
        chain_id)
    ret = eos_conn.chain_push_transaction(signed_transaction)

    return ret
Example #3
0
    def refreshkey2(self, symbol, token_id, new_subkey):

        message = subkey_signature_in_contract("refreshkey2",
                                               symbol,
                                               token_id=token_id,
                                               new_subkey=new_subkey)
        sig = check_sig.sign_message_with_privatekey(self.subprivatekey,
                                                     message, True)

        binargs = self.chain_abi_json_to_bin({
            "code": CONTRACT,
            "action": "refreshkey2",
            "args": {
                "sym": symbol,
                "token_id": token_id,
                "new_subkey": new_subkey,
                "sig": sig
            }
        })['binargs']

        transaction, chain_id = TransactionBuilder(
            self).build_sign_transaction_request(
                (Action(CONTRACT, 'refreshkey2', self.account, self.permission,
                        binargs), ))
        return self.push_transaction(transaction, chain_id)
Example #4
0
    def issuetoagent(self, symbol, subkey, memo):

        #get_last_id
        last_id = table_client.get_token_lastid(symbol)
        tokenId = last_id + 1

        #making sig
        a_day = 24 * 60 * 60
        message = subkey_signature_in_contract("issuetoagent", symbol)
        sig = check_sig.sign_message_with_privatekey(self.subprivatekey,
                                                     message,
                                                     isbyte=True)

        binargs = self.chain_abi_json_to_bin({
            "code": CONTRACT,
            "action": "issuetoagent",
            "args": {
                "sym": symbol,
                "token_id": tokenId,
                "subkey": subkey,
                "sig": sig,
                "memo": memo
            }
        })['binargs']

        transaction, chain_id = TransactionBuilder(
            self).build_sign_transaction_request(
                (Action(CONTRACT, 'issuetoagent', self.account,
                        self.permission, binargs), ))
        return self.push_transaction(transaction, chain_id)
Example #5
0
    def system_newaccount(self, creator_account, created_account, owner_key,
                          active_key, stake_net_quantity, stake_cpu_quantity,
                          transfer, buy_ram_kbytes):
        newaccount_binargs = self.get_system_newaccount_binargs(
            creator_account, created_account, owner_key, active_key)
        buyrambytes_binargs = self.get_system_buyrambytes_binargs(
            creator_account, created_account, buy_ram_kbytes * 1024)
        delegatebw_binargs = self.get_system_delegatebw_binargs(
            creator_account, created_account, stake_net_quantity,
            stake_cpu_quantity, transfer)

        transaction, chain_id = TransactionBuilder(
            self).build_sign_transaction_request((
                Action('eosio', 'newaccount', creator_account, 'active',
                       newaccount_binargs),
                Action('eosio', 'buyrambytes', creator_account, 'active',
                       buyrambytes_binargs),
                Action('eosio', 'delegatebw', creator_account, 'active',
                       delegatebw_binargs),
            ))

        available_public_keys = self.wallet_get_public_keys()
        required_public_keys = self.chain_get_required_keys(
            transaction, available_public_keys)['required_keys']
        signed_transaction = self.wallet_sign_transaction(
            transaction, required_public_keys, chain_id)
        return self.chain_push_transaction(signed_transaction)
Example #6
0
    def transferid2(self, to, symbol, token_id):

        message = subkey_signature_in_contract("transferid2",
                                               symbol,
                                               token_id=token_id,
                                               to=to)
        sig = check_sig.sign_message_with_privatekey(self.subprivatekey,
                                                     message, True)

        binargs = self.chain_abi_json_to_bin({
            "code": CONTRACT,
            "action": "transferid2",
            "args": {
                "to": to,
                "sig": sig,
                "sym": symbol,
                "token_id": token_id,
                "memo": ""
            }
        })['binargs']

        transaction, chain_id = TransactionBuilder(
            self).build_sign_transaction_request(
                (Action(CONTRACT, 'transferid2', self.account, self.permission,
                        binargs), ))
        return self.push_transaction(transaction, chain_id)
    def addsellobyid(self,symbol,token_id,price,memo):

        binargs = self.chain_abi_json_to_bin({
            "code": CONTRACT, 
            "action": "addsellobyid",
            "args": {"sym": symbol,"token_id":token_id,"price":price,"memo":memo}
        })['binargs']

        transaction, chain_id = TransactionBuilder(self).build_sign_transaction_request((
            Action(CONTRACT, 'addsellobyid', self.account , self.permission, binargs),
        ))
        return self.push_transaction(transaction, chain_id)
    def cancelsobyid(self,symbol, token_id):

        binargs = self.chain_abi_json_to_bin({
            "code": CONTRACT, 
            "action": "cancelsobyid",
            "args": {"sym": symbol,"token_id":token_id}
        })['binargs']

        transaction, chain_id = TransactionBuilder(self).build_sign_transaction_request((
            Action(CONTRACT, 'cancelsobyid',self.account , self.permission, binargs),
        ))
        return self.push_transaction(transaction, chain_id)
    def buyfromorder(self, buyer, symbol, token_id, memo ):

        binargs = self.chain_abi_json_to_bin({
            "code": CONTRACT, 
            "action": "buyfromorder",
            "args": {"sym": symbol,"token_id":token_id,"memo":memo}
        })['binargs']

        transaction, chain_id = TransactionBuilder(self).build_sign_transaction_request((
            Action(CONTRACT, 'buyfromorder',self.account , self.permission, binargs),
        ))
        return self.push_transaction(transaction, chain_id)
    def cancelsello(self,quantity):

        binargs = self.chain_abi_json_to_bin({
            "code": CONTRACT, 
            "action": "cancelsello",
            "args": {"seller": self.account,"quantity":quantity}
        })['binargs']

        transaction, chain_id = TransactionBuilder(self).build_sign_transaction_request((
            Action(CONTRACT, 'cancelsello',self.account , self.permission, binargs),
        ))

        return self.push_transaction(transaction, chain_id)
    def withdraw(self,value, memo):

        binargs = self.chain_abi_json_to_bin({
            "code": CONTRACT, 
            "action": "withdraw",
            "args": {"user":self.account,"value":value,"memo":memo}
        })['binargs']

        transaction, chain_id = TransactionBuilder(self).build_sign_transaction_request((
            Action(CONTRACT, 'withdraw',self.account , self.permission, binargs),
        ))

        return self.push_transaction(transaction, chain_id)
Example #12
0
    def create(self, symbol):

        binargs = self.chain_abi_json_to_bin({
            "code": CONTRACT,
            "action": "create",
            "args": {
                "issuer": self.account,
                "sym": symbol
            }
        })['binargs']

        transaction, chain_id = TransactionBuilder(
            self).build_sign_transaction_request(
                (Action(CONTRACT, 'create', self.account, self.permission,
                        binargs), ))
        return self.push_transaction(transaction, chain_id)
Example #13
0
    def refreshkey(self, symbol, token_id, new_subkey):

        binargs = self.chain_abi_json_to_bin({
            "code": CONTRACT,
            "action": "refreshkey",
            "args": {
                "sym": symbol,
                "token_id": token_id,
                "new_subkey": new_subkey
            }
        })['binargs']

        transaction, chain_id = TransactionBuilder(
            self).build_sign_transaction_request(
                (Action(CONTRACT, 'refreshkey', self.account, self.permission,
                        binargs), ))
        return self.push_transaction(transaction, chain_id)
Example #14
0
    def issue(self, given_user, quantity, memo):

        binargs = self.chain_abi_json_to_bin({
            "code": CONTRACT,
            "action": "issue",
            "args": {
                "user": given_user,
                "quantity": quantity,
                "memo": memo
            }
        })['binargs']

        transaction, chain_id = TransactionBuilder(
            self).build_sign_transaction_request(
                (Action(CONTRACT, 'issue', self.account, self.permission,
                        binargs), ))

        return self.push_transaction(transaction, chain_id)
Example #15
0
    def system_newaccount(self, creator_account, created_account, owner_key,
                          active_key, stake_net_quantity, stake_cpu_quantity,
                          transfer, buy_ram_kbytes):
        newaccount_binargs = self.get_system_newaccount_binargs(
            creator_account, created_account, owner_key, active_key)
        buyrambytes_binargs = self.get_system_buyrambytes_binargs(
            creator_account, created_account, buy_ram_kbytes * 1024)
        delegatebw_binargs = self.get_system_delegatebw_binargs(
            creator_account, created_account, stake_net_quantity,
            stake_cpu_quantity, transfer)

        transaction, chain_id = TransactionBuilder(
            self).build_sign_transaction_request((
                Action('eosio', 'newaccount', creator_account, 'active',
                       newaccount_binargs),
                Action('eosio', 'buyrambytes', creator_account, 'active',
                       buyrambytes_binargs),
                Action('eosio', 'delegatebw', creator_account, 'active',
                       delegatebw_binargs),
            ))

        available_public_keys = self.wallet_get_public_keys()
        required_public_keys = self.chain_get_required_keys(
            transaction, available_public_keys)['required_keys']
        signed_transaction = self.wallet_sign_transaction(
            transaction, required_public_keys, chain_id)
        return self.chain_push_transaction(signed_transaction)


# w = Client(wallet_endpoint='http://localhost:8900')
# w.system_newaccount(
#     'tokenika4eos', 'perduta1test',
#     'EOS7VdRNSwuoUWjYEP4vG4Kz2Xe4HWHUDKxcHbqkAjoT2wk17ZB1y',
#     'EOS7VdRNSwuoUWjYEP4vG4Kz2Xe4HWHUDKxcHbqkAjoT2wk17ZB1y',
#     '0.2500 EOS', '0.2500 EOS', True, 8
# )