Similar questions have been asked before, and I have read them but am stuck after using encode_single. If I pass the resulting bytes into my solidity function it says "expected list or tuple, got bytes"

Here is my encoding ->
depositdata=encode_single('(string,address,address[],uint256[],uint256[],bytes[])',('aave','0x6b175474e89094c44da98b954eedeac495271d0f',['0x6b175474e890 94c44da98b954eedeac495271d0f'],[100],[250000000000000000000],[]))

It outputs a properly encoded bytes section. However, when I pass it into my solidity function, even as [depositdata], I get the same error.

Any ideas?

2 Answers 2


I solved the issue. Sending structs into functions in brownie is actually very easy.

The struct is of the form

struct depositData { 
     string depositConnectorName;
     address vaultToken;
     address[] depositTokens;
     uint256[] depositTokenFractions;
     uint256[] newDepositAmount;
     bytes[] depositConnectorData;

And the function moveFunds(depositData[] calldata data) {} can be called like this: contract[0].moveFunds([['aave','0x6b175474e89094c44da98b954eedeac495271d0f',['0x6b175474e89094c44da98b954eedeac495271d0f'],[100],[250*10**18],[]]],{'from': accounts[0]})

What solved my issue was not to encode the data, but to simply send it as a list of structs. my function was requesting a list of depositData structs, so I had to add another [] around it.

Hope this helps someone.


I had the same issue, you can solve it by 2 methods :

First :

in solidity Code :

struct YOUR_STRUCT {
uint id;
address owner }

YOUR_STRUCT[] public your_struct;

in Brownie code

id = youDeployedContract.your_struct(0)["id"]
owner = youDeployedContract.your_struct(0)["owner"]

When the 0 is your array index

Second :

create a view function returns the array elements;

solidity code :

function getOverview(uint index) public view returns(uint,address){
YOUR_STRUCT storage your_str = your_struct[index] ;
return (you_str.id,your_str.owner);

Brownie code

id,owner = yourDeployedContract.getOverview(0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.