Skip to content

Instantly share code, notes, and snippets.

View bee344's full-sized avatar

Alberto Nicolas Penayo bee344

View GitHub Profile
@bee344
bee344 / hardhat.config.ts
Last active August 14, 2025 21:28
Tests to check functionality of dirty node
import { HardhatUserConfig } from "hardhat/config"
import "@nomicfoundation/hardhat-toolbox"
import "@parity/hardhat-polkadot-node"
import "@parity/hardhat-polkadot-resolc"
const config: HardhatUserConfig = {
solidity: "0.8.28",
networks: {
hardhat: {
polkavm: true,
@bee344
bee344 / parallel-results.log
Created June 20, 2025 16:25
Results of OZ test suite
AccountECDSA
entryPoint
1) "before each" hook for "should return the canonical entrypoint"
Account
entryPoint
2) "before each" hook for "should return the canonical entrypoint"
import '@polkadot/api-augment'
import { Keyring } from "@polkadot/api";
import { ApiPromise, WsProvider } from '@polkadot/api';
import { hexToU8a, u8aToHex } from '@polkadot/util';
import { cryptoWaitReady } from "@polkadot/util-crypto";
import { construct, getRegistry, methods } from '@substrate/txwrapper-polkadot';
async function main() {
const wsProvider = new WsProvider('wss://westend-rpc.polkadot.io');
@bee344
bee344 / Polkagochi.sol
Created December 4, 2024 10:59
Polkagochi.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
contract Polkagochi {
struct MyPolkagochi {
address payable owner;
string name;
uint256 id;
uint8 age;
uint256 hunger;
@bee344
bee344 / index.js
Created June 13, 2024 10:54
Simple balance transfer
const { Keyring } = require("@polkadot/keyring");
const { ApiPromise, WsProvider } = require("@polkadot/api");
const { cryptoWaitReady } = require("@polkadot/util-crypto");
async function main() {
/**
* Here we set our local Asset Hub node as the wsProvider
*/
const wsProvider = new WsProvider("ws://127.0.0.1:9944");
import { WsProvider, ApiPromise } from '@polkadot/api';
import { GenericEvent } from '@polkadot/types';
import { DispatchError, EventRecord } from '@polkadot/types/interfaces';
const provider = new WsProvider('ws//');
const api = new ApiPromise({ provider });
/**
* You must have the block number where the extrinsic is to know which block to query.
@bee344
bee344 / README.md
Last active March 15, 2024 16:20
How to manually retrieve stakin payouts

The goal of this document is to provide a user-friendly guide to calculate the staking payouts for validators in the Polkadot Relay Chain manually, that is without employing Substrate Sidecar API.

The calculation for the payout for each validator/nominator for an era is best described in the Polkadot Wiki, but in sinthesis the payout for the validator depends on the points earned during that era, its stake and it's commission. For the Nominator, on other hand, it depends on its stake and the points and commissions of its backed validators.

To calculate the payout for an era for a validator, we need the following data:

  • Validator's commission (commission)
@bee344
bee344 / snowbridge.md
Created January 12, 2024 00:18
Snowbridge from the ATA perspective

Snowbridge is a general purpose, trustless and decentralized bridge between Polkadot and Ethereum. Snowbridge provides a bridge between the BridgeHub parachain and their Gateway on Ethereum, in the form of a Smart Contract.

Ethereum > Asset Hub

In short, to send tokens from Ethereum to an Asset Hub there is a necessary condition that needs to be met; the ERC20 token needs to be registered in the Asset Hub as a ForeignAsset. For this, the Gateway.sol smart contract enables the registerToken function that takes care of registering a new token on the Asset Hub as a MultiAsset with id = { parents: 2, interior: X2 :[ { GlobalConsensus: Ethereum { chainId: } },{ AccountKey20: { network: '', key: } } ] } . This only needs to be done once and can be done by a

Keybase proof

I hereby claim:

  • I am bee344 on github.
  • I am bee344 (https://keybase.io/bee344) on keybase.
  • I have a public key ASC4j8xbGNHCao1o2Q77k1S0qFw83ayQsr3JRUrZUhAe3go

To claim this, I am signing this object: