Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,21 @@ yarn add @base-org/account
3. Request accounts to initialize a connection to wallet

```js
const addresses = provider.request({
const addresses = await provider.request({
method: 'eth_requestAccounts',
});
```

4. Make more requests

```js
provider.request('personal_sign', [
`0x${Buffer.from('test message', 'utf8').toString('hex')}`,
addresses[0],
]);
provider.request({
method: 'personal_sign',
params: [
`0x${Buffer.from('test message', 'utf8').toString('hex')}`,
addresses[0],
],
});
```

5. Handle provider events
Expand Down
15 changes: 9 additions & 6 deletions packages/account-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,21 @@
3. Request accounts to initialize a connection to wallet

```js
const addresses = provider.request({
const addresses = await provider.request({
method: 'eth_requestAccounts',
});
```

4. Make more requests

```js
provider.request('personal_sign', [
`0x${Buffer.from('test message', 'utf8').toString('hex')}`,
addresses[0],
]);
provider.request({
method: 'personal_sign',
params: [
`0x${Buffer.from('test message', 'utf8').toString('hex')}`,
addresses[0],
],
});
```

5. Handle provider events
Expand Down Expand Up @@ -127,7 +130,7 @@

## Script Tag Usage

Base Accunt can be used directly in HTML pages via a script tag, without any build tools:
Base Account can be used directly in HTML pages via a script tag, without any build tools:

```html
<!-- Via unpkg -->
Expand Down
13 changes: 5 additions & 8 deletions packages/account-sdk/src/interface/payment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,23 @@ The payment interface provides a simple way to make USDC payments on Base networ
import { pay } from '@base-org/account';

// Basic payment
// pay() resolves on success and throws on failure
const payment = await pay({
amount: "10.50",
to: "0xFe21034794A5a574B94fE4fDfD16e005F1C96e51",
dataSuffix: "0xabc123",
testnet: true
});

if (payment.success) {
console.log(`Payment sent! Transaction ID: ${payment.id}`);
} else {
console.error(`Payment failed: ${payment.error}`);
}
console.log(`Payment sent! Transaction ID: ${payment.id}`);
```

## Checking Payment Status

You can check the status of a payment using the transaction ID returned from the pay function:

```typescript
import { getPaymentStatus } from '@base/account-sdk';
import { getPaymentStatus } from '@base-org/account';

// Check payment status
const status = await getPaymentStatus({
Expand All @@ -43,7 +40,7 @@ switch (status.status) {
console.log(`Payment completed! Amount: ${status.amount} to ${status.recipient}`);
break;
case 'failed':
console.log(`Payment failed: ${status.error}`);
console.log(`Payment failed: ${status.reason}`);
break;
case 'not_found':
console.log('Payment not found');
Expand Down Expand Up @@ -160,4 +157,4 @@ The payment result is always a successful payment (errors are thrown as exceptio
- `sender?: string` - Sender address (present for pending, completed, and failed)
- `amount?: string` - Amount sent (present for completed transactions, parsed from logs)
- `recipient?: string` - Recipient address (present for completed transactions, parsed from logs)
- `error?: string` - Error message (present for failed status - includes both on-chain failure reasons and off-chain errors)
- `reason?: string` - Reason for transaction failure (present for failed status - describes why the transaction failed on-chain)