1
//transaction struct of what a tx should have
struct Transaction{
    address to;
    uint value;
    bool executed;
    uint numConfirmations;
    mapping(address => bool) isConfirmed;
    mapping(address => bool) isRevoked;
}

//Array of transactions to keep track of each tx
Transaction[] public transactions;    

A Transaction struct and an array type of Transaction. I want to access any Transaction value in the array and use it to for testing with brownie. How can I do this?

Will appreciate your response!

1 Answer 1

1

You can do this:

# Get accoun
account = get_account()

# Deploy Contract
contract = ContractName.deploy(
    {"from": account}
)
# Retrieve the latest contract
contract = ContractName[-1]

print(contract.array_name(0))

Since transactions array is public, solidity automatically creates a getter function, which is the same name as your array. By making a call to this getter, you will get a tuple. For example: contract.array_name(0)[0] will print the first field of your struct.

0

Your Answer

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

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