I have s constructor that takes a bytes32 parameter and assign its value to the jobID variable

contract APIConsumer {

    bytes32 public jobId;

    constructor( bytes32 _jobId) {
        jobId = _jobId;

But when I pass the value "ec013753fda740f8bc74a966daea0723" in the constructor it assign this value to the jobId variable "0x00000000000000000000000000000000ec013753fda740f8bc74a966daea0723" I want to know why it adds those zeros and how to fix it (make it assign the same value passed in the parameters and do not add zeros).

1 Answer 1


This is intended behavior, the value is padded right ( = zeroes are added to the left of your number to fill the entire 32 bytes). I don't think you actually want to "fix" this, but if you do, you could use a byte array instead, like so:

bytes public jobId;

constructor( bytes  memory _jobId) {
    jobId = _jobId;

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.