StarkNet Graffitis

Hello!
I am creating this thread to discuss our first dapp on StarkNet: StarkNet Graffiti

Try to deploy it yourself on testnet and see how easy it is!

16 Likes

Hi Henri, thanks so much for setting all this up - this was originally sent on Discord. Hopefully this is useful to other people trying to figure out what’s going on. Annoyingly I can only insert two links per post…

So, the message I sent was this:
27718767270208698038738470982482014384883115712124593200217941362

Candy dandy, liquor quicker
On Voyager here.

It wasn’t previously (but now is) on Etherscan, but I could still view the payload I sent (begins 277187) - transaction 118, find by searching for the contract 0xC010818276Eb5dFF6CC462217C66EE7648Fb8d8B. In twitter you said “Sending on L2 is free, consuming on L1 is not” – so how come I can view it? Or has someone already paid for the L1 transaction?

So I could in theory deploy my own instance of a new graffiti contract to mainnet alpha / testnet and do the same thing, just using the new contract I’ve created? Or do I need to do a bunch of stuff at setup (just looking at the invoke bit, you’ve hard-coded an address) / get permission from Starknet? I’m not part of a team, just curious. When you say what I was looking at was the hash of my message, I’d have assumed that it would be encrypted - why would someone pay on L1 to consume something that’s already visible for free (or am I mistaken and it was just being processed)? I also don’t quite see how graffFromStarknetOnMainnet gets the addresses / hashes it needs to know it’s working on my particular message (I think some are built in by you when it was invoked, but not clear what you passed to the function to make it appear).

Thanks!

12 Likes

Great question!

In twitter you said “Sending on L2 is free, consuming on L1 is not” – so how come I can view it? Or has someone already paid for the L1 transaction?

When you use send_message_to_l1 in a Cairo contract, it creates an outbound message to L1. This message is then sent, along with the state updates, to L1, by the sequencer.

The message is sent in full (as you can see, in the place where you found it).
The payload is passed as calldata in an event, and is not kept (this is why you see it in an event).
The hash of the message is kept in storage, for later retrieval. This allows consuming a message only once.

Obviously, this has a cost (emitting events on L1 is costly). So once StarkNet has fee metering, using send_message_to_l1 in your code will incur a fee. Right now, we don’t have fees, so I get to go funny tutorials, that don’t cost you anything :slight_smile:

So I could in theory deploy my own instance of a new graffiti contract to mainnet alpha / testnet and do the same thing, just using the new contract I’ve created?

You can absolutely do this on testnet, where anyone can deploy contracts. On mainnet, we restrict the ability to deploy contracts for now; so you would have to go through us, yes.

why would someone pay on L1 to consume something that’s already visible for free (or am I mistaken and it was just being processed)?

For a simple event like this, you are right; we could have just let things as is.
However, remember that the actual payload of your message is not stored in the smart contract on L1 during state update; the payload is passed as calldata. While you, human (presumabely), are able to see it, a smart contract can not. So we need to pass the actual message as parameters to our smart contract, when we call it later on.

I also don’t quite see how graffFromStarknetOnMainnet gets the addresses / hashes it needs to know it’s working on my particular message

When I use consumeMessageFromL2 in my solidity smart contract, I need to specify who is the sender, and the payload. The message hash is computed by the StarknetCore instance on L1 (look here file StarknetMessaging.sol line 71)
The L2 sender I query from the L1 contract is set by me, the owner of the L1 contract, using this function.

Does that help? let me know if you have any further question!

13 Likes

Thanks so much for the explainer - yes, I think that answers everything. I think the simplicity of the payload was the thing that was confusing me (ironically). I’m going to spend some time messing with the testnet!

11 Likes