1

I'm trying to write a smart contract which will deploy byte code using assembly op_code create. I'm following this post.

But when I call deployCode function I got nothing. Ropsten etherscan tells me that I've exceeded gas limit. See here. But this contract costs only 1-2 millions of gas.

What I'm doing wrong?

1

You were trying to deploy ASCII, not bytecode.

You can have a look at what your contract actually tried to create by checking the parity trace of the transaction: https://ropsten.etherscan.io/vmtrace?txhash=0x068629bdf944db9a7458fe4b723f1b26916d8d15cf3ff01afec67ac7cca22e55&type=parity

If you run Web3.utils.toAscii on the code you were deploying it comes out to:

(Note, you're missing a library anyway)

0x606060405236156100755763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631817702e811461007a5780633341dfe61461015c5780633416fd081461018f578063a87430ba146101ec578063bd1562731461022f578063df7bed6114610245575b600080fd5b341561008557600080fd5b61015a60046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803590602001908201803590602001908080601f01602080910402602001604051908101604052818152929190602084018383808284378201915050505050509190803590602001908201803590602001908080601f01602080910402602001604051908101604052818152929190602084018383808284375094965050509235600160a060020a031692506102f7915050565b005b341561016757600080fd5b61017b600160a060020a03600435166104cb565b604051901515815260200160405180910390f35b341561019a57600080fd5b61015a60048035600160a060020a03169060446024803590810190830135806020808202016040519081016040528093929190818152602001838360200280828437509496506104e895505050505050565b34156101f757600080fd5b61020b600160a060020a03600435166105d9565b60405192835260208301919091526040808301919091526060909101905180910390f35b341561023a57600080fd5b61017b6004356105fa565b341561025057600080fd5b6102a460048035600160a060020a03169060446024803590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061060f95505050505050565b60405160208082528190810183818151815260200191508051906020019060200280838360005b838110156102e35780820151838201526020016102cb565b505050509050019250505060405180910390f35b6000610302826104cb565b1561030c57600080fd5b50600160a060020a0381166000908152602081905260408082209160029187919051602001526040518082805190602001908083835b602083106103615780518252601f199092019160209182019101610342565b6001836020036101000a03801982511681845116808217855250505050505090500191505060206040518083038160008661646e5a03f115156103a357600080fd5b505060405180518255506002846000604051602001526040518082805190602001908083835b602083106103e85780518252601f1990920191602091820191016103c9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060206040518083038160008661646e5a03f1151561042a57600080fd5b505060405180516001830155506002836000604051602001526040518082805190602001908083835b602083106104725780518252601f199092019160209182019101610453565b6001836020036101000a03801982511681845116808217855250505050505090500191505060206040518083038160008661646e5a03f115156104b457600080fd5b505060405180516002909201919091555050505050565b600160a060020a0316600090815260208190526040902054151590565b6000806104f4846104cb565b15156104ff57600080fd5b5050600160a060020a0382166000908152602081905260408120905b82518110156105d3576001600084838151811061053457fe5b90602001906020020151815260208101919091526040016000205460ff16151561055d57600080fd5b81600301600084838151811061056f57fe5b906020019060200201518152602081019190915260400160002080546001810161059983826107c1565b506000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff191633600160a060020a031617905560010161051b565b50505050565b60006020819052908152604090208054600182015460029092015490919083565b60016020526000908152604090205460ff1681565b6106176107ea565b6000610622846104cb565b151561062d57600080fd5b60008085600160a060020a0316600160a060020a03168152602001908152602001600020905080600301600073__Common________________________________63cfb51928866000604051602001526040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b838110156106e55780820151838201526020016106cd565b50505050905090810190601f1680156107125780820380516001836020036101000a031916815260200191505b509250505060206040518083038186803b151561072e57600080fd5b6102c65a03f4151561073f57600080fd5b50505060405180519050600019166000191681526020019081526020016000208054806020026020016040519081016040528092919081815260200182805480156107b357602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610795575b505050505091505092915050565b8154818355818115116107e5576000838152602090206107e59181019083016107fc565b505050565b60206040519081016040526000815290565b61081a91905b808211156108165760008155600101610802565b5090565b905600a165627a7a72305820588dbb211a5e024f525210cc1fda21288862c7694eb08920d4882ee579853d2e0029

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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