Skip to content

Commit

Permalink
feat(PSDK-782): allow users to send sponsored transactions immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
0xRAG committed Jan 9, 2025
1 parent f378518 commit 05030e8
Show file tree
Hide file tree
Showing 14 changed files with 1,161 additions and 9 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pip install cdp-sdk
```

if you prefer to manage dependencies with Poetry:

```bash
poetry add cdp-sdk
```
Expand Down Expand Up @@ -155,6 +156,12 @@ print(f"Faucet transaction successfully completed: {usdc_faucet_tx}")
transfer = wallet1.transfer(0.00001, "usdc", wallet3, gasless=True).wait()
```

By default, gasless transfers are batched with other transfers, and might take longer to submit. If you want to opt out of batching, you can set the `skip_batching` option to `True`, which will submit the transaction immediately.

```python
transfer = wallet1.transfer(0.00001, "usdc", wallet3, gasless=True, skip_batching=True).wait()
```

### Listing Transfers

```python
Expand Down Expand Up @@ -239,7 +246,9 @@ fetched_wallet.load_seed(file_path)
```

### Creating a Webhook

A webhook is a way to provide other applications with real-time information from the blockchain. When an event occurs on a blockchain address, it can send a POST request to a URL you specify. You can create a webhook to receive notifications about events that occur in your wallet or crypto address, such as when a user makes a transfer.

```python
from cdp.client.models.webhook import WebhookEventType
from cdp.client.models.webhook import WebhookEventFilter
Expand All @@ -252,10 +261,13 @@ wh1 = Webhook.create(
)
print(wh1)
```

In the above example, parameter `network_id` is optional, if not provided, the default network is `base-sepolia`. Today we support Base mainnet and Base Sepolia networks.

### Creating a Webhook On A Wallet

A webhook can be attached to an existing wallet to monitor events that occur on the wallet, i.e. all addresses associated with this wallet. A list of supported blockchain events can be found [here](https://docs.cdp.coinbase.com/get-started/docs/webhooks/event-types).

```python
import cdp

Expand All @@ -265,9 +277,9 @@ print(wh1)
```

## Examples

Examples, demo apps, and further code samples can be found in the [CDP SDK Python Documentation](https://docs.cdp.coinbase.com/cdp-apis/docs/welcome).

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.

2 changes: 2 additions & 0 deletions cdp/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
from cdp.client.models.asset import Asset
from cdp.client.models.balance import Balance
from cdp.client.models.broadcast_contract_invocation_request import BroadcastContractInvocationRequest
from cdp.client.models.broadcast_external_transfer_request import BroadcastExternalTransferRequest
from cdp.client.models.broadcast_staking_operation_request import BroadcastStakingOperationRequest
from cdp.client.models.broadcast_trade_request import BroadcastTradeRequest
from cdp.client.models.broadcast_transfer_request import BroadcastTransferRequest
Expand All @@ -70,6 +71,7 @@
from cdp.client.models.contract_invocation_list import ContractInvocationList
from cdp.client.models.create_address_request import CreateAddressRequest
from cdp.client.models.create_contract_invocation_request import CreateContractInvocationRequest
from cdp.client.models.create_external_transfer_request import CreateExternalTransferRequest
from cdp.client.models.create_fund_operation_request import CreateFundOperationRequest
from cdp.client.models.create_fund_quote_request import CreateFundQuoteRequest
from cdp.client.models.create_payload_signature_request import CreatePayloadSignatureRequest
Expand Down
Loading

0 comments on commit 05030e8

Please sign in to comment.