-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
4f37319
commit 64dd6a1
Showing
7 changed files
with
130 additions
and
78 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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
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
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,38 @@ | ||
import { | ||
HttpTransport, | ||
LocalECDSAKeySigner, | ||
PublicClient, | ||
WalletV1, | ||
} from "@nilfoundation/niljs"; | ||
|
||
export async function createClient(): Promise<{ | ||
wallet: WalletV1; | ||
publicClient: PublicClient; | ||
}> { | ||
const walletAddress = process.env.WALLET_ADDR; | ||
|
||
if (!walletAddress) { | ||
throw new Error("WALLET_ADDR is not set in environment variables"); | ||
} | ||
|
||
const publicClient = new PublicClient({ | ||
transport: new HttpTransport({ | ||
endpoint: walletAddress, | ||
}), | ||
shardId: 1, | ||
}); | ||
|
||
const signer = new LocalECDSAKeySigner({ | ||
privateKey: `0x${process.env.PRIVATE_KEY}`, | ||
}); | ||
const pubkey = await signer.getPublicKey(); | ||
|
||
const wallet = new WalletV1({ | ||
pubkey: pubkey, | ||
address: walletAddress, | ||
client: publicClient, | ||
signer, | ||
}); | ||
|
||
return { wallet, publicClient }; | ||
} |