-
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.
Merge pull request #406 from 00labs/declare-payment-tokenid
SDK declare payment by token id
- Loading branch information
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
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,37 @@ | ||
import { BigNumber, Wallet, ethers } from 'ethers' | ||
import { ChainEnum, POOL_NAME, POOL_TYPE } from '@huma-finance/shared' | ||
import { HumaReceivableHandler, HumaContext } from '@huma-finance/sdk' | ||
require('dotenv').config() | ||
|
||
async function main() { | ||
const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY | ||
const provider = new ethers.providers.JsonRpcProvider( | ||
`https://rpc-amoy.polygon.technology`, | ||
{ | ||
name: 'Amoy', | ||
chainId: ChainEnum.Amoy, | ||
}, | ||
) | ||
const wallet = new Wallet(TEST_PRIVATE_KEY, provider) | ||
|
||
const humaContext = new HumaContext({ | ||
signer: wallet, | ||
provider, | ||
chainId: ChainEnum.Amoy, | ||
poolName: POOL_NAME.ArfCreditPoolV2, | ||
poolType: POOL_TYPE.ReceivableBackedCreditLine, | ||
}) | ||
const receivableHandler = new HumaReceivableHandler({ | ||
humaContext, | ||
}) | ||
|
||
// Mint a receivable with metadata uploaded to ARWeave | ||
const tx = await receivableHandler.declarePaymentByTokenId( | ||
BigNumber.from(10), // receivableAmount | ||
BigNumber.from(1), // token ID | ||
) | ||
const txResponse = await tx.wait() | ||
console.log(`Success. Tx hash: ${txResponse.transactionHash}`) | ||
} | ||
|
||
main() |
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