Exemplo n.º 1
0
def approve(contract_address,
            pay_address,
            get_address,
            amount,
            node_index=None,
            errorcode=47001,
            errorkey="error"):
    request = {
        "REQUEST": {
            "Qid": "t",
            "Method": "signeovminvoketx",
            "Params": {
                "gas_price":
                0,
                "gas_limit":
                1000000000,
                "address":
                contract_address,
                "version":
                1,
                "params": [{
                    "type": "string",
                    "value": "approve"
                }, {
                    "type":
                    "array",
                    "value": [{
                        "type":
                        "bytearray",
                        "value":
                        Common.bl_reserver(
                            Common.base58_to_address(pay_address))
                    }, {
                        "type":
                        "bytearray",
                        "value":
                        Common.bl_reserver(
                            Common.base58_to_address(get_address))
                    }, {
                        "type": "int",
                        "value": amount
                    }]
                }]
            }
        },
        "RESPONSE": {
            "error": errorcode
        },
        "NODE_INDEX": node_index
    }
    if (errorkey == "error_code"):
        request["SIGN_RESPONSE"] = {errorkey: errorcode}
    return API.contract().call_contract(Task(name="approve", ijson=request),
                                        twice=True)
Exemplo n.º 2
0
	def multi_sig_transfer(neo_contract_address, from_address, to_address, amount, m, pubkey_array, node_index=0):
		request = {
				"REQUEST":  {
				"Qid": "t",
				"Method": "signeovminvoketx",
				"Params": {
					"gas_price": 0,
					"gas_limit": 1000000000,
					"address": neo_contract_address,
					"version": 1,
					"params": [
						{
							"type": "string",
							"value": "transfer"
						},
						{	
							"type" : "string",
							"value" : ""
						},
						{
							"type": "array",
							"value": [
								{
									"type": "bytearray",
									"value": Common.bl_reserver(Common.base58_to_address(from_address))
								},
								{
									"type": "bytearray",
									"value": Common.bl_reserver(Common.base58_to_address(to_address))
								},
								{
									"type": "int",
									"value": amount
								}
							]
						}
					]
				}
			},
			"RESPONSE":{"error" : 0},
			"NODE_INDEX":node_index
		}

		return CONTRACT_API.call_multisig_contract(Task(name="multi_sig_transfer", ijson=request), m, pubkey_array)
Exemplo n.º 3
0
	def transfer(contract_address,from_address,to_address,amount, node_index = None):
		request = {
			"REQUEST": {
				"Qid": "t",
				"Method": "signeovminvoketx",
				"Params": {
					"gas_price": 0,
					"gas_limit": 1000000000,
					"address": contract_address,
					"version": 1,
					"params": [
						{
							"type": "string",
							"value": "transfer"
						},
						{	
							"type" : "string",
							"value" : ""
						},
						{
							"type": "array",
							"value":  [
								{
									"type": "bytearray",
									
									"value": Common.bl_reserver(Common.base58_to_address(from_address))
								},
								{
									"type": "bytearray",
									"value": Common.bl_reserver(Common.base58_to_address(to_address))
								},
								{
									"type": "int",
									"value": amount
								}
							]
						}
					]
				}
			},
			"RESPONSE":{"error" : 0},
			"NODE_INDEX":node_index
		}
		return API.contract().call_contract(Task(name="transfer", ijson=request), twice = True)
Exemplo n.º 4
0
def balanceOf(contract_address, address, node_index=None, errorcode=47001):
    request = {
        "REQUEST": {
            "Qid": "t",
            "Method": "signeovminvoketx",
            "Params": {
                "gas_price":
                0,
                "gas_limit":
                1000000000,
                "address":
                contract_address,
                "version":
                1,
                "params": [{
                    "type": "string",
                    "value": "balanceOf"
                }, {
                    "type":
                    "array",
                    "value": [{
                        "type":
                        "bytearray",
                        "value":
                        Common.bl_reserver(Common.base58_to_address(address))
                    }]
                }]
            }
        },
        "RESPONSE": {
            "error": errorcode
        },
        "NODE_INDEX": node_index
    }
    return API.contract().call_contract(Task(name="balanceOf", ijson=request),
                                        twice=True)