当前位置: 首页>>代码示例>>Python>>正文


Python utils.checksum_encode方法代码示例

本文整理汇总了Python中ethereum.utils.checksum_encode方法的典型用法代码示例。如果您正苦于以下问题:Python utils.checksum_encode方法的具体用法?Python utils.checksum_encode怎么用?Python utils.checksum_encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ethereum.utils的用法示例。


在下文中一共展示了utils.checksum_encode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from ethereum import utils [as 别名]
# 或者: from ethereum.utils import checksum_encode [as 别名]
def __init__(self,
                     contract_address,
                     contract_abi_string,
                     ethereum_chain_id,
                     http_provider,
                     websocket_provider,
                     gas_price_gwei,
                     gas_limit,):

            self.abi_dict = json.loads(contract_abi_string)
            self.contract_address = utils.checksum_encode(contract_address)
            self.ethereum_chain_id = int(ethereum_chain_id)

            self.w3 = Web3(HTTPProvider(http_provider))
            # self.wsw3 = Web3(WebsocketProvider(websocket_provider))

            self.contract = self.w3.eth.contract(address=self.contract_address, abi=self.abi_dict)
            self.decimals = self.get_decimals()

            self.gas_price = self.w3.toWei(gas_price_gwei, 'gwei')
            self.gas_limit = gas_limit
            self.transaction_max_value = self.gas_price * self.gas_limit 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:24,代码来源:ethereum_processor.py

示例2: deploy_safes

# 需要导入模块: from ethereum import utils [as 别名]
# 或者: from ethereum.utils import checksum_encode [as 别名]
def deploy_safes(number, owners, private_key):
    safes = []
    funding_public_key = checksum_encode(privtoaddr(private_key))
    funding_nonce = w3.eth.getTransactionCount(funding_public_key, 'pending')
    for _ in range(number):
        payload_json = generate_payload(owners)
        r = requests.post(SAFES_URL, json=payload_json)
        assert r.ok
        safe_created = r.json()
        safe_address = safe_created['safe']
        payment = int(safe_created['payment'])

        logging.info('Created safe=%s, need payment=%d', safe_address, payment)
        send_eth(private_key, safe_address, payment, funding_nonce)
        logging.info('Sent payment=%s to safe=%s', payment, safe_address)
        r = requests.put(get_safes_notify_url(safe_address))
        assert r.ok
        funding_nonce += 1
        safes.append(safe_address)

    with open('safes.txt', mode='a') as safes_file:
        safes_file.write('\n'.join(safes))


# notify_safes() 
开发者ID:gnosis,项目名称:safe-relay-service,代码行数:27,代码来源:create_multiple_safes.py

示例3: generate_approval_txn

# 需要导入模块: from ethereum import utils [as 别名]
# 或者: from ethereum.utils import checksum_encode [as 别名]
def generate_approval_txn(self):

        sender_address = utils.checksum_encode(self.master_wallet_address)

        approve_amount = self.cents_to_native_amount(10 ** 8)

        transfer_approval_txn = self.contract.functions.approve(sender_address, approve_amount)

        return transfer_approval_txn 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:11,代码来源:ethereum_processor.py

示例4: handle

# 需要导入模块: from ethereum import utils [as 别名]
# 或者: from ethereum.utils import checksum_encode [as 别名]
def handle(self, *args, **options):
        pages = options['pages'] or 3
        download = options['download_icons'] or options['download_folder']
        download_folder = options['download_folder'] or os.path.join(settings.STATIC_ROOT, 'tokens')
        store_db = options['store_db']
        token_repository = TokenRepository()
        tokens = token_repository.get_tokens(pages=pages)
        self.stdout.write(self.style.SUCCESS(str(tokens)))
        if store_db:
            for i, token in enumerate(tokens):
                symbol = token['symbol']
                relevance = 0 if symbol == 'GNO' else i + 1
                token_db, created = Token.objects.get_or_create(
                    address=checksum_encode(token['address']),
                    defaults={
                        'name': token['name'],
                        'symbol': symbol,
                        'description': token['description'],
                        'decimals': token['decimals'],
                        'logo_uri': token['logo_url'] if token['logo_url'] else '',
                        'website_uri': token['website_url'],
                        'gas': False,
                        'relevance': relevance
                    }
                )
                if token_db.relevance != relevance:
                    token_db.relevance = relevance
                    token_db.save(update_fields=['relevance'])
                    self.stdout.write(self.style.SUCCESS('%s changed relevance to %d' % (token['name'], relevance)))

                if created:
                    self.stdout.write(self.style.SUCCESS('Inserted new token %s' % token['name']))

        if download:
            token_repository.download_images_for_tokens(folder=download_folder,
                                                        token_addresses=[token['address'] for token in tokens]) 
开发者ID:gnosis,项目名称:safe-relay-service,代码行数:38,代码来源:update_tokens.py

示例5: __init__

# 需要导入模块: from ethereum import utils [as 别名]
# 或者: from ethereum.utils import checksum_encode [as 别名]
def __init__(self, private_key=None):
        self.private_key = private_key
        if private_key is None:
            self.private_key = SigningKey.generate(curve=SECP256k1).to_string().hex()
        self._raw_address = utils.privtoaddr(self.private_key)
        self.address = utils.checksum_encode(self._raw_address) 
开发者ID:Lamden,项目名称:clove,代码行数:8,代码来源:wallet.py

示例6: get_watched_contract_addresses

# 需要导入模块: from ethereum import utils [as 别名]
# 或者: from ethereum.utils import checksum_encode [as 别名]
def get_watched_contract_addresses(self, contract) -> Set[str]:
        addresses = None
        try:
            if contract.get('ADDRESSES'):
                addresses = contract['ADDRESSES']
            elif contract.get('ADDRESSES_GETTER_CLASS'):
                addresses = contract['ADDRESSES_GETTER_CLASS'].get_addresses()
        except Exception as e:
            raise LookupError("Could not retrieve watched addresses for contract {}".format(contract['NAME'])) from e

        normalized_addresses = {checksum_encode(address) for address in addresses}
        return normalized_addresses 
开发者ID:gnosis,项目名称:django-eth-events,代码行数:14,代码来源:event_listener.py

示例7: mk_validation_code

# 需要导入模块: from ethereum import utils [as 别名]
# 或者: from ethereum.utils import checksum_encode [as 别名]
def mk_validation_code(address):
    return serpent.compile(code_template % (utils.checksum_encode(address)))

# Install RLP decoder library 
开发者ID:ethereum,项目名称:research,代码行数:6,代码来源:simple_casper_tester.py

示例8: generate_key_pair

# 需要导入模块: from ethereum import utils [as 别名]
# 或者: from ethereum.utils import checksum_encode [as 别名]
def generate_key_pair() -> Tuple[str, str]:
    private_key = utils.sha3(os.urandom(4096))
    public_key = utils.checksum_encode(utils.privtoaddr(private_key))
    return private_key, public_key 
开发者ID:gnosis,项目名称:pm-trading-db,代码行数:6,代码来源:factories.py

示例9: parse_blockchain_task

# 需要导入模块: from ethereum import utils [as 别名]
# 或者: from ethereum.utils import checksum_encode [as 别名]
def parse_blockchain_task(self, task):

        print('-----------------------------------------------------------------')
        print('{} parsing task:'.format(datetime.datetime.utcnow()))
        print(task)

        type = task.get('type')
        transfer_amount = task.get('transfer_amount')
        sender = task.get('sender')
        recipient = task.get('recipient')
        account_to_approve_encoded_pk = task.get('account_to_approve_pk')
        credit_transfer_id = task.get('credit_transfer_id')
        master_wallet_approval_status = task.get('master_wallet_approval_status')
        uncompleted_tasks = task.get('uncompleted_tasks')
        is_retry = task.get('is_retry')

        if sender:
            sender = utils.checksum_encode(sender)

        if recipient:
            recipient = utils.checksum_encode(recipient)

        if type == 'DISBURSEMENT':
            self.make_disbursement(transfer_amount=transfer_amount,
                                   recipient_address=recipient,
                                   account_to_approve_encoded_pk=account_to_approve_encoded_pk,
                                   master_wallet_approval_status=master_wallet_approval_status,
                                   uncompleted_tasks=uncompleted_tasks,
                                   is_retry=is_retry,
                                   credit_transfer_id=credit_transfer_id)

        elif type == 'WITHDRAWAL':

            self.make_withdrawal(transfer_amount=transfer_amount,
                                 sender_address=sender,
                                 recipient_address=recipient,
                                 account_to_approve_encoded_pk=account_to_approve_encoded_pk,
                                 master_wallet_approval_status=master_wallet_approval_status,
                                 uncompleted_tasks=uncompleted_tasks,
                                 is_retry=is_retry,
                                 credit_transfer_id=credit_transfer_id)


        else:

            self.make_payment(transfer_amount=transfer_amount,
                              sender_address=sender,
                              recipient_address=recipient,
                              account_to_approve_encoded_pk=account_to_approve_encoded_pk,
                              master_wallet_approval_status=master_wallet_approval_status,
                              uncompleted_tasks=uncompleted_tasks,
                              is_retry=is_retry,
                              credit_transfer_id=credit_transfer_id) 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:55,代码来源:ethereum_processor.py


注:本文中的ethereum.utils.checksum_encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。