示例#1
0
    def mint(self, toAddress: str, amount: str):
        nonce = ''.join(
            random.choice(string.ascii_uppercase + string.ascii_lowercase +
                          string.digits) for _ in range(8))
        timestamp = int(round(time.time() * 1000))

        path = '/v1/service-tokens/' + self.contractId + '/mint'

        request_body = {
            'ownerAddress': self.ownerAddress,
            'ownerSecret': self.ownerSecret,
            'toAddress': toAddress,
            'amount': amount
        }

        headers = {
            'service-api-key': self.service_api_key,
            'nonce': nonce,
            'timestamp': str(timestamp),
            'Content-Type': 'application/json'
        }

        signature = get_signature('POST',
                                  path,
                                  nonce,
                                  timestamp,
                                  self.service_api_secret,
                                  body=request_body)
        headers['signature'] = signature

        res = requests.post(self.server_url + path,
                            headers=headers,
                            json=request_body)
        return res.json()
示例#2
0
    def transfer(self, fromAddress: str, walletSecret: str, toAddress: str,
                 tokenIndex: str):
        # transfer non fungible item tokens
        # tokenId = concat(tokenType, tokenIndex)

        nonce = ''.join(
            random.choice(string.ascii_uppercase + string.ascii_lowercase +
                          string.digits) for _ in range(8))
        timestamp = int(round(time.time() * 1000))

        path = '/v1/wallets/' + fromAddress + '/item-tokens/' + self.contractId + '/non-fungibles/' + self.tokenType + '/' + tokenIndex + '/transfer'

        request_body = {'walletSecret': walletSecret, 'toAddress': toAddress}

        headers = {
            'service-api-key': self.service_api_key,
            'nonce': nonce,
            'timestamp': str(timestamp),
            'Content-Type': 'application/json'
        }

        signature = get_signature('POST',
                                  path,
                                  nonce,
                                  timestamp,
                                  self.service_api_secret,
                                  body=request_body)
        headers['signature'] = signature

        res = requests.post(self.server_url + path,
                            headers=headers,
                            json=request_body)
        return res.json()
示例#3
0
    def update_info(self, number: str, name: str, meta: str = None):
        nonce = ''.join(
            random.choice(string.ascii_uppercase + string.ascii_lowercase +
                          string.digits) for _ in range(8))
        timestamp = int(round(time.time() * 1000))

        path = '/v1/item-tokens/' + self.contractId + '/non-fungibles/' + self.tokenType + '/' + number

        request_body = {
            'ownerAddress': self.ownerAddress,
            'ownerSecret': self.ownerSecret,
            'name': name,
            'meta': meta
        }

        headers = {
            'service-api-key': self.service_api_key,
            'nonce': nonce,
            'timestamp': str(timestamp),
            'Content-Type': 'application/json'
        }

        signature = get_signature('PUT',
                                  path,
                                  nonce,
                                  timestamp,
                                  self.service_api_secret,
                                  body=request_body)
        headers['signature'] = signature

        res = requests.put(self.server_url + path,
                           headers=headers,
                           json=request_body)
        return res.json()
示例#4
0
    def get_info(self):
        nonce = ''.join(
            random.choice(string.ascii_uppercase + string.ascii_lowercase +
                          string.digits) for _ in range(8))
        timestamp = int(round(time.time() * 1000))

        path = '/v1/service-tokens'

        headers = {
            'service-api-key': self.service_api_key,
            'nonce': nonce,
            'timestamp': str(timestamp)
        }

        signature = get_signature('GET', path, nonce, timestamp,
                                  self.service_api_secret)
        headers['signature'] = signature

        res = requests.get(self.server_url + path, headers=headers)
        return res.json()
示例#5
0
    def holder(self, number: str):
        nonce = ''.join(
            random.choice(string.ascii_uppercase + string.ascii_lowercase +
                          string.digits) for _ in range(8))
        timestamp = int(round(time.time() * 1000))

        path = '/v1/item-tokens/' + self.contractId + '/non-fungibles/' + self.tokenType + '/' + number + '/holder'

        headers = {
            'service-api-key': self.service_api_key,
            'nonce': nonce,
            'timestamp': str(timestamp)
        }

        signature = get_signature('GET', path, nonce, timestamp,
                                  self.service_api_secret)
        headers['signature'] = signature

        res = requests.get(self.server_url + path, headers=headers)
        return res.json()
示例#6
0
    def holders(self):
        nonce = ''.join(
            random.choice(string.ascii_uppercase + string.ascii_lowercase +
                          string.digits) for _ in range(8))
        timestamp = int(round(time.time() * 1000))

        path = '/v1/service-tokens/' + self.contractId + '/holders'

        query_params = {'limit': 10, 'orderBy': 'desc', 'page': 1}

        headers = {
            'service-api-key': self.service_api_key,
            'nonce': nonce,
            'timestamp': str(timestamp)
        }

        signature = get_signature('GET', path, nonce, timestamp,
                                  self.service_api_secret, query_params)
        headers['signature'] = signature

        res = requests.get(self.server_url + path,
                           params=query_params,
                           headers=headers)
        return res.json()