Skip to content

Instantly share code, notes, and snippets.

@Realkayzee
Realkayzee / array_emulator.cairo
Created January 16, 2024 23:26
Starknet Array Emulator
// This is a simple book storage contract
// where users store list of books they bookmarekd to read.
// users can also delete them after acheving their goal of reading them.
// similar to Todo
// the legacy map used in this contract mimicks array
// using the LIFO pattern (last in, first out)
#[starknet::interface]
export const projectId = "91123e3eafe4c736a115f6e3f6484a47";
export const api_keys = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweEI4OTFmNGY4NEQwNjY1MGIwOTViNWYzZjgyMUYyMUYyMTU0NjQ3MDciLCJpc3MiOiJuZnQtc3RvcmFnZSIsImlhdCI6MTY4NzY0NDA4MzI1OSwibmFtZSI6IlZlbmRhbyJ9.rvQvuQitUMttFWkFAW0gZZU7ohpT4UNc_Or0Bm8u0qc"
import getContract from "./utils/getContract.js";
const { ethers: etherjs } = ethers;
async function getTodoList() {
const contract = getContract();
try {
const response = await contract.getTodos();
const formatted = response.map((item) => {
return {
name: item[0],
import abi from "./abi.js";
import openTab from "./tab.js";
const { ethers: etherjs } = ethers;
const rpcUrl = "https://goerli.infura.io/v3/ba80361523fe423bb149026a490266f0";
const signerProvider = new etherjs.providers.Web3Provider(window.ethereum);
const provider = new etherjs.providers.JsonRpcProvider(rpcUrl);
const signer = signerProvider.getSigner();
uint256 constant SALARY=20000;
struct Workers{
uint8 count;
string name;
}
library Arithmetic{
function add(uint a,uint b) internal pure returns(uint){
@Realkayzee
Realkayzee / cast.sol
Last active September 16, 2022 17:51
import "./LibCast.sol";
contract Cast{
using Arithmetic for uint;
using Arithmetic for Arithmetic.Workers;
Arithmetic.Workers aw;
uint tem;
//SPDX-License-Identifier: GPL-3.0;
pragma solidity 0.8.7;
contract Energy{
//have total supply
//transferrable
//name
//SPDX-License-Identifier: MIT;
pragma solidity 0.8.7;
contract DepositFund{
mapping(address=>uint) balance;
function deposit() public payable{
//SPDX-License-Identifier: MIT
pragma solidity 0.8.7;
contract CountAfterSeconds{
uint public count;
uint today;
constructor(){
today = block.timestamp;