I am trying to call the Maker CDP Contract manager smart contract.
I want to get the information from this public mapping in the contract.
mapping (bytes32 => Cup) public cups
and should return a mapping:
struct Cup {
address lad; // CDP owner
uint256 ink; // Locked collateral (in SKR)
uint256 art; // Outstanding normalised debt (tax only)
uint256 ire; // Outstanding normalised debt
}
Where bytes32 should be a bytes representation of the CDPId. They have a python implementation that passes a value to this mapping from a function that looks like this.
def int_to_bytes32(value: int) -> bytes:
assert(isinstance(value, int))
return value.to_bytes(32, byteorder='big'
I've tried this:
myContract.methods.cups(web3.utils.fromAscii("5")).call(
function (err, res){
console.log(res)
}
)
However, I cannot figure out for my life how to pass the proper ID of say 5 to the bytes32 mapping and return the proper output. Everything returns with 0's even though I know that is incorrect.
Any help is appreciated.