Skip to content

Instantly share code, notes, and snippets.

View nakajo2011's full-sized avatar

Yukishige Nakajo nakajo2011

View GitHub Profile
@nakajo2011
nakajo2011 / MyNFT.js
Last active January 15, 2025 14:56
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
// hardhat ignition module
// filepath: ignition/modules/MyNFT.js
const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");
module.exports = buildModule("MyNFTModule", (m) => {
const token = m.contract("MyNFT", [], {});
return { token };
});
@nakajo2011
nakajo2011 / HashtableExample.sol
Created January 9, 2025 16:49
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
struct Hashtable {
mapping(address => uint) valueMap;
address[] keys;
}
function put(Hashtable storage self, address key, uint value) returns(bool) {
if(self.valueMap[key] != 0) {
@nakajo2011
nakajo2011 / CallerSample.sol
Last active January 9, 2025 07:23
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
contract Storage {
uint256 number;
function store(uint256 num) public {
number = num;
}
@nakajo2011
nakajo2011 / contracts...BitShiftTest.sol
Created June 12, 2024 05:39
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.26+commit.8a97fa7a.js&optimize=false&runs=200&gist=
pragma solidity >=0.8 <0.9.0;
/**
* @title Storage
* @dev Store & retrieve value in a variable
* @custom:dev-run-script ./scripts/deploy_with_ethers.ts
*/
contract BitShiftTest {
uint256 number;
@nakajo2011
nakajo2011 / contracts...BlindTransfer.sol
Created January 4, 2023 11:23
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.17+commit.8df45f5f.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* @title FlashTransfer
* @dev Simple blind transfer contract
*/
contract BlindTransfer {
@nakajo2011
nakajo2011 / App.tsx
Created May 3, 2021 08:35
Apollo Client/Getting Started sample4
import React from 'react';
import './App.css';
import './ExchangeRates'
import ExchangeRates from "./ExchangeRates";
export default function App() {
return (
<div>
<h2>My first Apollo app 🚀</h2>
@nakajo2011
nakajo2011 / index.tsx
Created May 3, 2021 08:29
Apollo Client/Getting Started sample3
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import fetch from 'cross-fetch';
import { gql, ApolloProvider, ApolloClient, HttpLink, InMemoryCache } from '@apollo/client';
const endpoint = 'https://48p1r2roz4.sse.codesandbox.io' // apolloのGetting Started
@nakajo2011
nakajo2011 / ExchangeRates.tsx
Last active May 3, 2021 08:31
Apollo Client/Getting Started sample2
import {gql, useQuery} from '@apollo/client';
const EXCHANGE_RATES = gql`
query GetExchangeRates {
rates(currency: "USD") {
currency
rate
}
}
`;
@nakajo2011
nakajo2011 / index.mjs
Last active May 3, 2021 08:07
Apollo Client/Getting Started sample
import fetch from 'cross-fetch';
import { gql, ApolloClient, HttpLink, InMemoryCache } from '@apollo/client';
const client = new ApolloClient({
link: new HttpLink({ uri: 'https://48p1r2roz4.sse.codesandbox.io', fetch }),
cache: new InMemoryCache()
});
client
.query({
query: gql`
query GetRates {
@nakajo2011
nakajo2011 / ModExp.sol
Created March 16, 2021 10:26
ModExp sample on Solidity
pragma solidity ^0.8.1;
contract ModExpContracts {
address public constant modExpAddress = 0x0000000000000000000000000000000000000005;
bytes public _result;
function modExp(
uint baseLength,