I've been trying to understand how the deploy() in web3 works, but I can't find any source that helps me. I wanna know how deploy() in web3 interacts with Ethereum blockchain and deploys a smart contract. please help me understand the flow, Thanks in advance :)

1 Answer 1


this is deploy(). it creates a transaction. Deployment of a smart contract is done by sending a transaction to the network with bytecode.

Contract.prototype.deploy = function(options, callback){

    options = options || {};

    options.arguments = options.arguments || [];
    options = this._getOrSetDefaultOptions(options);

    // throw error, if no "data" is specified
    if(!options.data) {
        if (typeof callback === 'function'){
            return callback(errors.ContractMissingDeployDataError());
        throw errors.ContractMissingDeployDataError();

    var constructor = this.options.jsonInterface.find((method) => {
        return (method.type === 'constructor');
    }) || {};
    constructor.signature = 'constructor';

    return this._createTxObject.apply({
        method: constructor,
        parent: this,
        deployData: options.data,
        _ethAccounts: this.constructor._ethAccounts
    }, options.arguments);

this is deployData: options.data actually the bytecode. we are sending the bytecode to evm and evm stores it in an address then we interact with this bytecode

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.