Skip to content

Instantly share code, notes, and snippets.

View Darlington02's full-sized avatar

Darlington Nnam Darlington02

View GitHub Profile
@Darlington02
Darlington02 / test_account.cairo
Created December 24, 2023 05:00
account test
use starknet::{ContractAddress, contract_address_to_felt252, account::Call};
use traits::TryInto;
use array::{ArrayTrait, SpanTrait};
use result::ResultTrait;
use option::OptionTrait;
use integer::u256_from_felt252;
use snforge_std::{declare, start_prank, stop_prank, ContractClassTrait, ContractClass, io::PrintTrait};
use token_bound_accounts::account::account::IAccountDispatcher;
use token_bound_accounts::account::account::IAccountDispatcherTrait;
@Darlington02
Darlington02 / Token.sol
Created October 19, 2023 18:41
ERC20 token for class on smart contract testing
//SPDX-License-Identifier: MIT
pragma solidity >= 0.8.0 < 0.9.0;
contract ERC20 {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
@Darlington02
Darlington02 / IICO.sol
Created September 18, 2023 11:45
Interface for ICO smart contract
pragma solidity >=0.8.0;
interface IICO {
event registered(address indexed _address, bool status);
event claimed(address indexed _address, bool status);
function register() external payable;
function claim(address _address) external returns(bool);
}
%lang starknet
from starkware.cairo.common.math import assert_nn
from starkware.cairo.common.cairo_builtins import HashBuiltin
@storage_var
func balance() -> (res: felt) {
}
@constructor
func constructor{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}(input: felt) {
@Darlington02
Darlington02 / Assignment A
Last active April 14, 2022 23:25
This gist contains the answers to the Conceptual Knowledge assignment for ZKU
WHAT IS A SMART CONTRACT? HOW ARE THEY DEPLOYED?
Technically speaking, smart contracts are computer programs intended to automatically execute, control or document legally relevant events and actions according to the terms of a contract or agreement.
Deployment of a smart contract is a necessary step, one must take to make a smart contract available to everyone on the ethereum network. To deploy a contract:
1. You must first generate its bytecode through compilation. Since solidity is a high level programming language, you must convert it to a low-level language which can be understood by the Ethereum virtual machine.
2. You'll need to have ETH for gas fees.
3. You'll need a deployment script or plugin.
4. Lastly, you'll need to connect to an ethereum node, either by running yours or using API keys from providers like Infura or Alchemy.
Once you deploy your contract, it is given an Ethereum address like other accounts.
WHAT IS GAS? WHY IS GAS OPTIMIZATION SUCH A BIG FOCUS WHEN BUILDING SMART CONTRACTS?