If you don't want to pull your head off with arg encoding please note that there is now in web3JS vs 1.0 a method called
Check also encodeFunctionCall that will encode the whole function + arguments
If we take a look at the solidity doc Use of dynamic types
we use the offset in bytes to the start of their data area, measured from the start of the value encoding (i.e. not counting the first four bytes containing the hash of the function signature).
The following types are called “dynamic”:
bytes string T for any T
T[k] for any dynamic T and any k > 0
(T1,...,Tk) if any Ti is dynamic for 1 <= i <= k
All other types are called “static”.
NB: Address is the equivalent of a uint160
so in your example you will encode
_address the first parameter, a uint160 value padded to 32 bytes
will be 0x0000000000000000000000000000000000000000000000000000000000000080
(offset to start of data part of second parameter, 4*32 bytes, exactly the size of the head part)
(offset to start of data part of third parameter = offset to start of data part of first dynamic parameter + size of data part of first dynamic parameter = 4*32 + ???*32 )
- _blocknumber the uint256 value padded to 32 bytes
After this, the data part of the first dynamic argument
- number of bytes of _name
- _name value padded to 32 bytes on the right
Finally, we encode the data part of the second dynamic argument _choices
- number of elements of the array
- value of first element
- value of second element
- etc ...