Skip to content

Commit ca51f4b

Browse files
authored
Beta Merge (#96)
* Docs updates * Transaction Demo Codw
1 parent 373bcba commit ca51f4b

File tree

7 files changed

+32
-14
lines changed

7 files changed

+32
-14
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
</ul>
8989
<hr />
9090
<h4 align="center">Want to contribute? Then join the Imperium today!</h4>
91-
<p align="center"> To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
91+
<p align="center">To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
9292
<hr />
9393
<small>COPYRIGHT © 2025 VIAT, <a href="https://universalweb.io">UNIVERSAL WEB</a>, THE NEXUS</small>
9494
<br />

docs/content.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ <h4>BROAD CODE OBJECTIVES</h4>
8888
</ul>
8989
<hr />
9090
<h4 align="center">Want to contribute? Then join the Imperium today!</h4>
91-
<p align="center"> To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
91+
<p align="center">To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
9292
<hr />
9393
<small>COPYRIGHT © 2025 VIAT, <a href="https://universalweb.io">UNIVERSAL WEB</a>, THE NEXUS</small>
9494
<br />

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ <h4>BROAD CODE OBJECTIVES</h4>
102102
</ul>
103103
<hr />
104104
<h4 align="center">Want to contribute? Then join the Imperium today!</h4>
105-
<p align="center"> To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
105+
<p align="center">To help write content, make art, write code, share it, and or star this repo! All are welcome to the Nexus.</p>
106106
<hr />
107107
<small>COPYRIGHT © 2025 VIAT, <a href="https://universalweb.io">UNIVERSAL WEB</a>, THE NEXUS</small>
108108
<br />

examples/viat.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
// Generate two wallets in the Viat network.
55
// Two wallets interact and send each other some amount of VIAT.
66
import { Wallet, wallet } from '#viat/index';
7+
import { toSmallestUnit } from '#viat/math/coin';
78
const amy = await wallet();
89
const mitzi = await wallet();
910
console.log('WALLET', amy, mitzi);
1011
const mitziAddress = await mitzi.getAddress();
1112
console.log('MITZI ADDRESS', mitziAddress);
12-
amy.send(1n, mitziAddress);
13+
// Amounts must be in the smallest unit (e.g., wei for Ethereum, satoshi for Bitcoin).
14+
const sendAmount = toSmallestUnit(1n);
15+
const manaAmount = 10000n;
16+
const txBlock = await amy.createTransaction(sendAmount, mitziAddress, manaAmount);
17+
console.log('TX BLOCK', txBlock.block);
18+
console.log('RECEIPT BLOCK', txBlock.receipt.block);

viat/blocks/receipt/block.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class ReceiptBlock extends Block {
3535
}
3636
async configByTransactionBlock(blockObject, config) {
3737
const txBlockData = blockObject.getData();
38-
const txHash = blockObject.getHash();
38+
const txHash = blockObject.block.hash;
3939
this.appendToCore(txBlockData.core, txHash);
4040
}
4141
appendToCore(coreData, txHash) {

viat/blocks/transaction/block.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ class TransactionBlock extends Block {
2525
}
2626
// Receipt Hash Link
2727
// Block Hash (TX DATA || Receipt Meta?)
28-
async createReceipt(wallet) {
29-
this.receipt = await receiptBlock(this, wallet);
28+
async createReceipt() {
29+
this.receipt = await receiptBlock(this);
3030
return this;
3131
}
32-
getReceiptPath() {
33-
const filepath = getTransactionPathFromBlock(this);
32+
async getReceiptPath() {
33+
const filepath = await getTransactionPathFromBlock(this);
3434
return filepath;
3535
}
3636
blockSchema = transactionBlockSchema;

viat/wallet/wallet.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,27 @@ export class Wallet extends CryptoID {
1212
await this.initialize(config, optionalArg);
1313
return this;
1414
}
15-
async send(amount, receiver, mana = 1n) {
15+
async createTransaction(amount, receiver, mana = 1n) {
1616
const sender = await this.getAddress();
1717
const txBlock = await transactionBlock({
18-
amount,
19-
receiver,
20-
sender,
21-
mana
18+
core: {
19+
amount,
20+
receiver,
21+
sender,
22+
mana
23+
}
2224
});
25+
await txBlock.finalize();
26+
await txBlock.createReceipt();
27+
await txBlock.receipt.finalize();
2328
console.log('Transaction Block:', txBlock.block);
29+
return txBlock;
30+
}
31+
async send(amount, receiver, mana = 1n) {
32+
const txBlock = await this.createTransaction(amount, receiver, mana);
33+
// Here you would typically send the transaction to the network
34+
// This is a placeholder for the actual sending logic
35+
console.log(`Sending transaction of ${amount} to ${receiver} with mana ${mana}`);
2436
}
2537
}
2638
export function wallet(config) {

0 commit comments

Comments
 (0)