Skip to content

Instantly share code, notes, and snippets.

@extropyCoder
extropyCoder / flash2.move
Created August 14, 2024 08:39
Fixed Code
module 0x42::example {
struct Coin<T> {
amount: u64
}
struct Receipt<phantom T> {
amount: u64
}
public fun flash_loan<T>(_user: &signer, amount:u64): (Coin<T>, Receipt<T>) {
let (coin, fee) = withdraw(user, amount);
@extropyCoder
extropyCoder / flash1.move
Created August 14, 2024 08:37
Vulnerable code
module 0x42::example {
struct Coin<T> {
amount: u64
}
struct Receipt {
amount: u64
}
public fun flash_loan<T>(user: &signer, amount: u64): (Coin<T>, Receipt) {
@extropyCoder
extropyCoder / generics.move
Created August 14, 2024 08:34
Specifying abilities
module 0x42::example {
struct Table<phantom K: copy + drop, phantom V> has store {
handle: address,
}
public fun add<K: copy + drop, V>(table: &mut Table<K, V>, key: K, val: V) {
add_box<K, V, Box<V>>(table, key, Box { val })
}
}
@extropyCoder
extropyCoder / example1.move
Last active August 14, 2024 08:02
Move Security
// BAD CODE
module 0x42::example {
struct Subscription has key {
end_subscription: u64
}
entry fun registration(user: &signer, end_subscription: u64) {
let price = calculate_subscription_price(end_subscription);
@extropyCoder
extropyCoder / h5.move
Created August 12, 2024 18:46
Move Homework 5 Answer
module my_addr::homework5 {
struct Asset has drop {
value : u64,
flag : u8
}
public entry fun build_asset(value : u64, flag : u8) {
@extropyCoder
extropyCoder / h9.move
Created August 12, 2024 11:23
Homework 9 code
module my_addr::h9 {
use aptos_framework::object;
use std::signer;
use std::string::{String};
#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
struct ExampleObject has key {
module 0xcafe::h4 {
struct MyData has key, store {
value: u8
}
fun init_module(sender: &signer) {
// here we can initialise the data
}

Account Abstraction Part 2: From Theory to Execution

Exploring the Power of User Operations with Solidity

Introduction

In Part 1, we talked about the transformative potential of Account Abstraction and ERC-4337 within the Ethereum ecosystem, highlighting its pivotal role in enhancing user experience and security by merging the functionalities of externally owned accounts (EOAs) and contract accounts. As we transition from theory to hands-on practice in Part 2, our journey takes a practical turn, guiding you through setting up your development environment, deploying an EntryPoint contract, and preparing for executing user operations. This tutorial is designed to equip developers with the skills needed to implement Account Abstraction in their Ethereum projects. While we aim to make this guide accessible, a basic familiarity with using the terminal, npm commands, and the Hardhat environment will be beneficial. Such foundational knowledge will help you navigate the setup, deployment, and execution ph

@extropyCoder
extropyCoder / dcg.sol
Created July 5, 2023 14:48
Audit prep
// DogCoinGame is a game where players are added to the contract via the addPlayer function, they need to send 1 ETH to play.
// Once 200 players have entered, the UI will be notified by the startPayout event,
// and will pick 100 winners which will be added to the winners array, the UI will then call the payout function to pay each of the winners.
// The remaining balance will be kept as profit for the developers."
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract DogCoinGame is ERC20 {
@extropyCoder
extropyCoder / PuppyCoinGame.sol
Last active June 1, 2024 12:13
Audit example
// PuppyCoinGame is a game where players are added to the contract via the addPlayer function, they need to send 1 ETH to play.
// Once 200 players have entered, the UI will be notified by the startPayout event,
// and will pick 100 winners which will be added to the winners array, the UI will then call the payout function to pay each of the winners.
// The remaining balance will be kept as profit for the developers."
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract PuppyCoinGame is ERC20 {