alcueca Profile picture
Oct 24 15 tweets 3 min read Read on X
Today, I'm speedrunning Cairo.
First stop, "Moving from Solidity to Cairo" from the cairo-lang website, just to get an idea of what is that we are going to do.

cairo-lang.org/moving-from-so…
The thing that makes Cairo less scary after reading that article is that you don't need to know that much of what goes under the hood to get started. It's just another programming language so far.
Next stop, read the first few chapters of the cairo book to get a handle of the syntax. Variables and control flow is all you need to start.

book.cairo-lang.org
After that, I've just quickly installed the dev tools, and I'm going to code an ERC20 from what I remember from the first article, using the cairo book. Let's go.
The book, the tutorial and the compiler all disagree on how to create a mapping/dictionary.

Today, we dine in hell.
Removed all functionality and started again.
Instantiating a contract with constructor arguments has been achieved internally.
But all the constructor arguments need to be the same type, weird.
Off to discord we go.
Never mind, I learnt about casting.
Oh joy Image
Google is dead to me Image
I spent probably two hours trying to print an address to console before giving up and finding a different way to test that `balanceOf` works.

Having something as basic as an address to be an import gives me strong BigNumber vibes. Yikes.
Thanks to the good people at the discord I learnt that you can create arbitrary addresses as:

`let holder: ContractAddress = 1234.try_into().unwrap();`

The mint and transfer functions were a breeze, now stuck with nested mappings for allowances.
You don't fool me, I know that's not the actual error: Image
It meant "Type not found" ... as a parameter in the implementation 50 lines below.

Dick.
Almost there, I just need to test `transferFrom` and add events.

Alas, I've got to go get the kids from school. Time to stop.

Today, I got from zero to a working erc20 in cairo.

Tomorrow, I'll dig into the @ChakraChain codebase in @code4rena :D

Bring on the pain.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with alcueca

alcueca Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @alcueca

Jun 1, 2021
Since I mentioned that I started coding solidity three years ago, at the ripe old age of 38, many have asked me how to do the same.

There isn't a secret or a resource that is exceptionally better than the others, but here is my story.

giphy.com/gifs/dr-who-co…
I started in the summer of 2018, completing the cryptozombies.io tutorial. It took me about a week.

That was my first assignment as Blockchain Architect for now-defunct TechHQ.
I was given a month or so to retrain myself from being a corporate Solution Architect to design blockchain-based projects we could sell. I was the technical guy, in a three-person consultancy.

Our first chance was a few months later, in a deal to code @CementDAO
Read 30 tweets
Dec 17, 2020
You can get Dai flash loans from @yield!

As cheap as 2.5 bps and 600K gas!

Let's flash!
Yield has free flash minting of fyDai, and very low fees for fyDai/Dai trades that are close to maturity. You can combine those for cheap Dai flash loans.

And you can do so just by using this npm package ⚡️
npmjs.com/package/fydai-…
To use it you code a contract that inherits from it, deploy, and start flash borrowing. 💸

I deployed a dummy flash borrower in Kovan, that you can use yourself to practice. The fees are paid by the contract, so pump it with some Kovan Dai first!

kovan.etherscan.io/address/0xDd6b…
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(