Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Issue on docs

Abierto Apto para principiantes
#1,675 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
74/100
Tipo de issue
Documentación
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
javascript

Línea de trabajo

Comienza en /apps/builder-codes/builder-codes y consulta https://docs.base.org/llms.txt para localizar la estructura de documentación relevante y las páginas cercanas. Añade la guía proporcionada “Accept B20 payments”, incluido su ejemplo de JavaScript y los enlaces relacionados, y verifica después que la página se renderiza correctamente y que sus enlaces y el ejemplo de código están intactos.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Path: /apps/builder-codes/builder-codes> ## Documentation Index

Fetch the complete documentation index at: https://docs.base.org/llms.txt
Use this file to discover all available pages before exploring further.

Accept B20 payments

Accept B20 token payments in your app and match each transaction to an order with onchain memos.

B20 is an ERC-20 superset. Standard transfer, transferFrom, approve, balanceOf, and ERC-2612 permit all work, so an app that accepts ERC-20 tokens accepts B20 with no code changes.

B20's new features include transfer policies, pausing, supply caps, and memos. This guide uses the memo: transferWithMemo works like transfer, but also attaches a bytes32 reference such as an order ID and emits a Memo event immediately after the standard Transfer event. Your app can read that Memo event to tie each payment to an order.

Tag a payment with a memo

This example reads the token's decimals, sends a payment tagged with an order ID, then reads the memo back from the receipt. It uses your configured viem walletClient and publicClient:

import { parseUnits, stringToHex, hexToString, parseEventLogs } from 'viem';

const TOKEN    = '0xB200...'; // the B20 token you accept
const MERCHANT = '0x...';     // where payments land

const ABI = [
  { type: 'function', name: 'decimals', stateMutability: 'view', inputs: [], outputs: [{ type: 'uint8' }] },
  { type: 'function', name: 'transferWithMemo', stateMutability: 'nonpayable',
    inputs: [{ name: 'to', type: 'address' }, { name: 'amount', type: 'uint256' }, { name: 'memo', type: 'bytes32' }],
    outputs: [{ type: 'bool' }] },
  { type: 'event', name: 'Memo', inputs: [
    { name: 'caller', type: 'address', indexed: true },
    { name: 'memo',   type: 'bytes32', indexed: true },
  ] },
];

// Read decimals because B20 tokens range from 6 to 18.
const decimals = await publicClient.readContract({ address: TOKEN, abi: ABI, functionName: 'decimals' });

// Pay 10 tokens, tagging the transfer with an order ID.
const hash = await walletClient.writeContract({
  address: TOKEN, abi: ABI, functionName: 'transferWithMemo',
  args: [MERCHANT, parseUnits('10', decimals), stringToHex('order-42', { size: 32 })],
});

// The Memo event carries the order ID back. Read it from the receipt.
const receipt = await publicClient.waitForTransactionReceipt({ hash });
const [memo] = parseEventLogs({ abi: ABI, logs: receipt.logs, eventName: 'Memo' });
console.log(hexToString(memo.args.memo, { size: 32 }).replace(/\0+$/, '')); // "order-42"

To collect with an allowance instead of a direct transfer, use transferFromWithMemo. It emits the same Memo event.

Handle B20-specific reverts

A B20 transfer can revert where a standard ERC-20 would not. Surface these so a failed payment is visible, not silent:

  • PolicyForbids: the sender or recipient is not authorized by the token's transfer policy. Most tokens are open by default, but a regulated issuer can gate transfers with an allowlist or blocklist.
  • A paused transfer: the issuer paused the token's TRANSFER feature.

Call publicClient.simulateContract with the same arguments before sending. It raises these as typed errors before the user signs, so you can show the reason instead of a failed transaction.

Related pages

Image
Lenguaje dominante
JavaScript
Estrellas
337
Forks
798
Merge medio
13 h 7 min
PR fusionados (30 d)
57

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de base/docs

Todos los issues de base/docs

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.