Check out a free preview of the full A Tour of Web 3: Ethereum & Smart Contracts with Solidity course

The "Deploying Contract" Lesson is part of the full, A Tour of Web 3: Ethereum & Smart Contracts with Solidity course featured in this preview video. Here's what you'd learn in this lesson:

ThePrimeagen shares a couple of the constraints around deploying contracts. There is a size limit of 24Kb and when a contract is updated, it gets a new address. Any previous transactions are associated with the old contract.

Preview
Close

Transcript from the "Deploying Contract" Lesson

[00:00:00]
>> So what is the size of our finished contract? Well, we can find that out by doing a little simple thing. We're going to cat out our artifacts, our contracts, our hero, our hero.JSON. We're gonna pass it into JQ and do deployed bytecode. That gives us out this big thing, right?

[00:00:22]
This is what is deployed out to the network, right? So what I wanna do is, I'm gonna take this and I'm gonna pipe it to word count and do character count. There is 5313 nibbles but really there's actually 5300 and 11 nibbles, plus two quotes cuz remember, each one of these represents a nibble or four bits.

[00:00:42]
So we could take this and go this thing divided by 2 minus 1. So this is the true size of our contract, which is 2.655k. Now, you may not realize this, but contracts have a hard limit of 24k. Is our contract very complex? I mean, technically it's kind of complex.

[00:01:06]
But is it complex? No, it's actually a pretty small amount of code. I'm sure we all accidentally create more code than that doing almost anything. It's hard to even turn a corner without creating 24 kilobytes of code, right? It's a lot. I mean it's very little amounts of memory, correct?

[00:01:22]
So this is a very big problem that we're about to face, if we were to make this even slightly let's say we make a fighting tactic. If you fight you could generate a new NFT if you win, I mean how big would our contract be? We easily just shoot right into like 50k, right?

[00:01:37]
It will just blow up immediately, so not only that but we've had this problem and we've been asked this problem multiple times. Every time your contract gets deployed again, upgrade, bug fix, address changes. So let me ask the question, what happened if your contract accepted payments? Where would that money be?

[00:01:56]
Old contract. Where would all that data be associated with? Old contract. Who would have to pay to transfer data from there to the new contract? You would, right? I feel like I don't know, Maury Ballsteen from Zoolander here. That's what's gonna happen, is that you have to pay for all this stuff to happen because you're now changing contracts.

[00:02:20]
When you make a change, you deploy a new contract, you are not using your old contract. This is obviously a big problem, right? Well, actually it's not actually that big of a problem cuz there's actually a really good solution.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now