Skip to content

Commit 6151755

Browse files
committed
Added AI generated docs as base
1 parent f58da98 commit 6151755

12 files changed

Lines changed: 616 additions & 0 deletions

File tree

docs/api/api-reference.md

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
# API Reference
2+
3+
The PHPcoin API provides a set of endpoints for interacting with the blockchain. The API is accessible via HTTP and returns data in JSON format.
4+
5+
## Accounts
6+
7+
### getAddress
8+
9+
Converts a public key to a PHPcoin address.
10+
11+
* **URL:** `/api.php?q=getAddress`
12+
* **Method:** `GET`
13+
* **Parameters:**
14+
* `public_key` (string, required): The public key to convert.
15+
* **Example:**
16+
```
17+
/api.php?q=getAddress&public_key=...
18+
```
19+
20+
### getBalance
21+
22+
Returns the balance of a specific address.
23+
24+
* **URL:** `/api.php?q=getBalance`
25+
* **Method:** `GET`
26+
* **Parameters:**
27+
* `address` (string, required): The address to check.
28+
* **Example:**
29+
```
30+
/api.php?q=getBalance&address=...
31+
```
32+
33+
### getPendingBalance
34+
35+
Returns the pending balance of a specific address, which includes unconfirmed transactions.
36+
37+
* **URL:** `/api.php?q=getPendingBalance`
38+
* **Method:** `GET`
39+
* **Parameters:**
40+
* `address` (string, required): The address to check.
41+
* **Example:**
42+
```
43+
/api.php?q=getPendingBalance&address=...
44+
```
45+
46+
### getPublicKey
47+
48+
Returns the public key of a specific address.
49+
50+
* **URL:** `/api.php?q=getPublicKey`
51+
* **Method:** `GET`
52+
* **Parameters:**
53+
* `address` (string, required): The address to check.
54+
* **Example:**
55+
```
56+
/api.php?q=getPublicKey&address=...
57+
```
58+
59+
### generateAccount
60+
61+
Generates a new PHPcoin account.
62+
63+
* **URL:** `/api.php?q=generateAccount`
64+
* **Method:** `GET`
65+
* **Example:**
66+
```
67+
/api.php?q=generateAccount
68+
```
69+
70+
## Transactions
71+
72+
### getTransactions
73+
74+
Returns the latest transactions for a specific address.
75+
76+
* **URL:** `/api.php?q=getTransactions`
77+
* **Method:** `GET`
78+
* **Parameters:**
79+
* `address` (string, required): The address to check.
80+
* `limit` (integer, optional): The maximum number of transactions to return.
81+
* `offset` (integer, optional): The offset to start from.
82+
* **Example:**
83+
```
84+
/api.php?q=getTransactions&address=...&limit=10
85+
```
86+
87+
### getTransaction
88+
89+
Returns a specific transaction by its ID.
90+
91+
* **URL:** `/api.php?q=getTransaction`
92+
* **Method:** `GET`
93+
* **Parameters:**
94+
* `transaction` (string, required): The ID of the transaction.
95+
* **Example:**
96+
```
97+
/api.php?q=getTransaction&transaction=...
98+
```
99+
100+
### send
101+
102+
Sends a transaction to the network.
103+
104+
* **URL:** `/api.php?q=send`
105+
* **Method:** `POST`
106+
* **Parameters:**
107+
* `val` (float, required): The amount to send.
108+
* `dst` (string, required): The destination address.
109+
* `public_key` (string, required): The sender's public key.
110+
* `signature` (string, required): The transaction signature.
111+
* `date` (integer, required): The transaction date (Unix timestamp).
112+
* `message` (string, optional): A message to include with the transaction.
113+
* **Example:**
114+
```json
115+
{
116+
"val": 10.0,
117+
"dst": "...",
118+
"public_key": "...",
119+
"signature": "...",
120+
"date": 1678886400,
121+
"message": "Hello, world!"
122+
}
123+
```
124+
125+
## Blocks
126+
127+
### currentBlock
128+
129+
Returns the current block.
130+
131+
* **URL:** `/api.php?q=currentBlock`
132+
* **Method:** `GET`
133+
* **Example:**
134+
```
135+
/api.php?q=currentBlock
136+
```
137+
138+
### getBlock
139+
140+
Returns a specific block by its height.
141+
142+
* **URL:** `/api.php?q=getBlock`
143+
* **Method:** `GET`
144+
* **Parameters:**
145+
* `height` (integer, required): The height of the block.
146+
* **Example:**
147+
```
148+
/api.php?q=getBlock&height=12345
149+
```
150+
151+
### getBlockTransactions
152+
153+
Returns the transactions of a specific block.
154+
155+
* **URL:** `/api.php?q=getBlockTransactions`
156+
* **Method:** `GET`
157+
* **Parameters:**
158+
* `height` (integer, required): The height of the block.
159+
* **Example:**
160+
```
161+
/api.php?q=getBlockTransactions&height=12345
162+
```
163+
164+
## Node
165+
166+
### version
167+
168+
Returns the version of the node.
169+
170+
* **URL:** `/api.php?q=version`
171+
* **Method:** `GET`
172+
* **Example:**
173+
```
174+
/api.php?q=version
175+
```
176+
177+
### mempoolSize
178+
179+
Returns the number of transactions in the mempool.
180+
181+
* **URL:** `/api.php?q=mempoolSize`
182+
* **Method:** `GET`
183+
* **Example:**
184+
```
185+
/api.php?q=mempoolSize
186+
```
187+
188+
### nodeInfo
189+
190+
Returns information about the node.
191+
192+
* **URL:** `/api.php?q=nodeInfo`
193+
* **Method:** `GET`
194+
* **Example:**
195+
```
196+
/api.php?q=nodeInfo
197+
```
198+
199+
### getPeers
200+
201+
Returns a list of the node's peers.
202+
203+
* **URL:** `/api.php?q=getPeers`
204+
* **Method:** `GET`
205+
* **Example:**
206+
```
207+
/api.php?q=getPeers
208+
```
209+
210+
## Masternodes
211+
212+
### getMasternodes
213+
214+
Returns a list of all masternodes.
215+
216+
* **URL:** `/api.php?q=getMasternodes`
217+
* **Method:** `GET`
218+
* **Example:**
219+
```
220+
/api.php?q=getMasternodes
221+
```
222+
223+
### getMasternode
224+
225+
Returns a specific masternode by its address.
226+
227+
* **URL:** `/api.php?q=getMasternode`
228+
* **Method:** `GET`
229+
* **Parameters:**
230+
* `address` (string, required): The address of the masternode.
231+
* **Example:**
232+
```
233+
/api.php?q=getMasternode&address=...
234+
```
235+
236+
## Smart Contracts
237+
238+
### getSmartContract
239+
240+
Returns a specific smart contract by its address.
241+
242+
* **URL:** `/api.php?q=getSmartContract`
243+
* **Method:** `GET`
244+
* **Parameters:**
245+
* `address` (string, required): The address of the smart contract.
246+
* **Example:**
247+
```
248+
/api.php?q=getSmartContract&address=...
249+
```
250+
251+
### getSmartContractProperty
252+
253+
Reads a property of a smart contract.
254+
255+
* **URL:** `/api.php?q=getSmartContractProperty`
256+
* **Method:** `GET`
257+
* **Parameters:**
258+
* `address` (string, required): The address of the smart contract.
259+
* `property` (string, required): The name of the property to read.
260+
* `key` (string, optional): The key of the property, if it's a map.
261+
* **Example:**
262+
```
263+
/api.php?q=getSmartContractProperty&address=...&property=myProperty&key=myKey
264+
```
265+
266+
### getSmartContractInterface
267+
268+
Returns the interface of a smart contract.
269+
270+
* **URL:** `/api.php?q=getSmartContractInterface`
271+
* **Method:** `GET`
272+
* **Parameters:**
273+
* `address` (string, required): The address of the smart contract.
274+
* **Example:**
275+
```
276+
/api.php?q=getSmartContractInterface&address=...
277+
```
278+
279+
### getSmartContractView
280+
281+
Executes a view method of a smart contract.
282+
283+
* **URL:** `/api.php?q=getSmartContractView`
284+
* **Method:** `GET`
285+
* **Parameters:**
286+
* `address` (string, required): The address of the smart contract.
287+
* `method` (string, required): The name of the view method to execute.
288+
* `params` (string, optional): The parameters for the method, as a base64-encoded JSON string.
289+
* **Example:**
290+
```
291+
/api.php?q=getSmartContractView&address=...&method=myMethod&params=...
292+
```

docs/dapps/developing-dapps.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Developing Dapps
2+
3+
A Decentralized Application (Dapp) on PHPcoin is a web application that interacts with the PHPcoin blockchain. Dapps can be built using standard web technologies like PHP, HTML, and JavaScript.
4+
5+
## Dapp Structure
6+
7+
A Dapp is typically structured as a web page that is served by a web server. The Dapp's frontend is built with HTML and JavaScript, and it interacts with a PHPcoin node's API to get information from the blockchain and to send transactions.
8+
9+
The backend of a Dapp can be written in any language, but PHP is a natural choice for PHPcoin Dapps. The backend can be used to perform more complex operations, such as interacting with a database or calling external APIs.
10+
11+
## Interacting with the Blockchain
12+
13+
Dapps interact with the PHPcoin blockchain by making calls to a node's API. The API provides a set of endpoints for getting information about the blockchain, sending transactions, and interacting with smart contracts.
14+
15+
You can use any HTTP client to make calls to the API. In PHP, you can use the `file_get_contents()` function or the cURL library. In JavaScript, you can use the `fetch()` API or a library like Axios.
16+
17+
## Example Dapp
18+
19+
The `dapps/demo` directory contains a simple example Dapp that visualizes the PHPcoin network topology. This Dapp is a good starting point for learning how to develop Dapps on PHPcoin.
20+
21+
The Dapp's frontend is built with HTML and JavaScript, and it uses the `vivagraph.js` and `go.js` libraries to visualize the network graph. The Dapp's backend is written in PHP, and it uses the `file_get_contents()` function to call the node's API and get information about the network.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Installation
2+
3+
This guide will walk you through the process of installing a PHPcoin node on a Debian-based system (e.g., Ubuntu). The easiest way to install PHPcoin is by using the provided installation script, which automates the entire process.
4+
5+
## Prerequisites
6+
7+
Before you begin, you will need:
8+
9+
* A server running a Debian-based Linux distribution (e.g., Ubuntu 20.04, 22.04).
10+
* Root or `sudo` privileges on the server.
11+
12+
## Quick Installation
13+
14+
The following one-liner command will download and execute the installation script, setting up a PHPcoin node for the **mainnet**:
15+
16+
```bash
17+
curl -s https://phpcoin.net/scripts/install_node.sh | bash
18+
```
19+
20+
To install a node for the **testnet**, use the following command:
21+
22+
```bash
23+
curl -s https://phpcoin.net/scripts/install_node.sh | bash -s -- --network testnet
24+
```
25+
26+
## What the Script Does
27+
28+
The installation script performs the following steps:
29+
30+
1. **Updates System:** Updates the package manager and installs essential packages, including Nginx, PHP, and MariaDB.
31+
2. **Creates Database:** Sets up a new database and user for the PHPcoin node.
32+
3. **Downloads Node:** Clones the latest version of the PHPcoin source code from the official Git repository.
33+
4. **Configures Web Server:** Configures Nginx to serve the PHPcoin web interface.
34+
5. **Initializes Configuration:** Creates the necessary configuration files for the node.
35+
6. **Imports Blockchain:** Downloads and imports a recent snapshot of the blockchain to accelerate the initial synchronization process.
36+
7. **Starts Services:** Starts the Nginx and MariaDB services.
37+
38+
Once the installation is complete, you can access your PHPcoin node by opening the provided URL in your web browser.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Running a Node
2+
3+
Once you have installed your PHPcoin node, it will be running as a web application. You can access the web interface by navigating to the URL provided at the end of the installation process.
4+
5+
## Web Interface
6+
7+
The web interface provides a user-friendly way to interact with your node. It includes the following features:
8+
9+
* **Block Explorer:** Allows you to browse the blockchain, view blocks, and inspect transactions.
10+
* **Wallet:** Provides a simple and secure way to manage your PHPcoin wallet, send and receive coins, and view your transaction history.
11+
* **Network Information:** Displays information about the current state of the network, including the number of connected peers and the current block height.
12+
13+
## Command-Line Interface (CLI)
14+
15+
In addition to the web interface, PHPcoin provides a command-line interface (CLI) for more advanced users. The CLI scripts are located in the `cli/` directory and can be used to perform various tasks, such as:
16+
17+
* **Running the P2P Server:** The `server.php` script is used to run the node's peer-to-peer (P2P) server, which is responsible for communicating with other nodes on the network. To run the server, execute the following command from the root of your PHPcoin installation:
18+
19+
```bash
20+
php cli/server.php
21+
```
22+
23+
* **Synchronizing the Blockchain:** The `sync.php` script is used to manually trigger the synchronization of the blockchain. This is useful if your node has been offline for a while and needs to catch up with the rest of the network.
24+
25+
```bash
26+
php cli/sync.php
27+
```
28+
29+
* **Running Cron Jobs:** The `cron.php` script is designed to be run periodically to perform maintenance tasks, such as cleaning up old data and updating the list of peers.
30+
31+
```bash
32+
php cli/cron.php
33+
```
34+
35+
* **Mining:** The `miner.php` script can be used to mine PHPcoin from the command line.
36+
37+
```bash
38+
php cli/miner.php
39+
```
40+
41+
For most users, the web interface will be sufficient for interacting with the PHPcoin network. However, the CLI provides a powerful set of tools for those who want more control over their node.

0 commit comments

Comments
 (0)