-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6139228
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const helloWorld = async () => { | ||
const transaction = await pg.program.methods.helloWorld().transaction(); | ||
|
||
const transactionID = await web3.sendAndConfirmTransaction( | ||
pg.connection, | ||
transaction, | ||
[pg.wallet.keypair] | ||
); | ||
|
||
console.log( | ||
"Transaction Complete: ", | ||
`https://explorer.solana.com/tx/${transactionID}?cluster=devnet` | ||
); | ||
}; | ||
|
||
helloWorld(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
declare_id!("5UQcesyNGAypwzk8zudC2FL2fGrDYi4DyvEwGmmi7n45"); | ||
|
||
#[program] | ||
mod hello_anchor { | ||
use super::*; | ||
pub fn hello_world(_ctx: Context<HelloWorld>) -> Result<()> { | ||
msg!("Hello World from Solana Blockchain"); | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Accounts)] | ||
pub struct HelloWorld {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// No imports needed: web3, anchor, pg and more are globally available | ||
|
||
describe("HelloWorld", () => { | ||
it("HelloWorld", async () => { | ||
// Generate keypair for the new account | ||
const newAccountKp = new web3.Keypair(); | ||
|
||
const txHash = await pg.program.methods.helloWorld() | ||
.accounts({ | ||
newAccount: newAccountKp.publicKey, | ||
signer: pg.wallet.publicKey, | ||
systemProgram: web3.SystemProgram.programId, | ||
}) | ||
.signers([newAccountKp]) | ||
.rpc(); | ||
|
||
console.log(`Use 'solana confirm -v ${txHash} to see the logs`); | ||
|
||
// Confirm transaction | ||
await pg.connection.confirmTransaction(txHash); | ||
|
||
console.log("Hello World did") | ||
|
||
}); | ||
}); |