Digamos que tengo este contrato de ejemplo:
pragma solidity ^0.4.0;
contract SEexample {
int256[3] thing;
uint8 internal i=0;
function submit(int256[3] bids,int256[3] prefs) public returns (int256[3]){
for (i=0;i<3;i++){
thing[i] = bids[i] + prefs[i];
}
return thing;
}
}
Dando este abi:
[
{
"constant": false,
"inputs": [
{
"name": "bids",
"type": "int256[3]"
},
{
"name": "prefs",
"type": "int256[3]"
}
],
"name": "submit",
"outputs": [
{
"name": "",
"type": "int256[3]"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
]
Y despliego usando web3.py:
from web3 import Web3, HTTPProvider, IPCProvider
w3 = Web3(HTTPProvider('http://localhost:8545')) //(testrpc)
tx_hash = contract.deploy(transaction={'from': w3nce.eth.accounts[0], 'gas': 10000000})
tx_receipt = w3.eth.getTransactionReceipt(tx_hash)
contract_address = tx_receipt['contractAddress']
contract_instance = w3.eth.contract(address=contract_address, abi=abi, ContractFactoryClass=ConciseContract)
¿Cómo instruyo a Python para que cumpla con el int256[13] que requiere la función?
He probado variaciones en:
import numpy as np
a=np.ones((3,),dtype=int)
b=np.ones((3,),dtype=int)
x=contract_instance.submit(a,b, transact={'from': w3.eth.accounts[1]})
también con a.tobytes()
,b.tobytes()
Resultados en :
raise ValueError("No matching functions found")
ValueError: no se encontraron funciones coincidentes
Esto parece funcionar:
x=contract_instance.submit(a.tolist(),b.tolist(), transact={'from': w3.eth.accounts[1]})