Skip to content
Merged
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
10 changes: 10 additions & 0 deletions .bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ cwhois() {
whois -h bgp.tools -v $*
}
export -f cwhois

# etherscan_api: Make POST requests to Etherscan API v2
# Usage: etherscan_api [options]
# Example: etherscan_api -H 'Content-Type: application/json' -d '{"module":"contract","action":"getabi","address":"0x..."}'
etherscan_api() {
curl --request POST \
--url https://api.etherscan.io/v2/api \
"$@"
}
export -f etherscan_api
55 changes: 51 additions & 4 deletions BASHRC.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

This repository includes a `.bashrc` file with custom bash functions.

## cwhois Function
## Functions

### cwhois Function

The `cwhois` function is a custom whois wrapper that queries bgp.tools for network information.

### Usage
#### Usage

To use the `cwhois` function, source the `.bashrc` file in your shell:

Expand All @@ -20,7 +22,7 @@ Then you can use the function:
cwhois <query>
```

### Example
#### Example

```bash
# Query information about an IP address or AS number
Expand All @@ -30,7 +32,7 @@ cwhois AS15169

The function automatically adds the `-v` (verbose) flag and queries the bgp.tools whois server.

### How it works
#### How it works

The function is defined as:
```bash
Expand All @@ -41,3 +43,48 @@ export -f cwhois
```

This wraps the standard `whois` command to always use the bgp.tools server with verbose output enabled (`-v` flag).

### etherscan_api Function

The `etherscan_api` function is a wrapper for making POST requests to the Etherscan API v2 endpoint.

#### Usage

To use the `etherscan_api` function, source the `.bashrc` file in your shell:

```bash
source .bashrc
```

Then you can use the function with standard curl options:

```bash
etherscan_api [curl options]
```

#### Examples

```bash
# Make a POST request with JSON data
etherscan_api -H "Content-Type: application/json" -d '{"module":"contract","action":"getabi","address":"0x..."}'

# Add an API key as a query parameter
etherscan_api -d 'module=contract&action=getabi&address=0x...&apikey=YOUR_API_KEY'

# Use with chainid parameter for v2 API
etherscan_api -d 'chainid=2201&module=contract&action=getsourcecode&address=0x...&apikey=YOUR_API_KEY'
```

#### How it works

The function is defined as:
```bash
etherscan_api() {
curl --request POST \
--url https://api.etherscan.io/v2/api \
"$@"
}
export -f etherscan_api
```

This wraps the `curl` command to always make POST requests to the Etherscan API v2 endpoint (`https://api.etherscan.io/v2/api`), while allowing you to pass any additional curl options through the function arguments.