irys-xyz / js-sdk Goto Github PK
View Code? Open in Web Editor NEWJS SDK for Irys on Arweave
JS SDK for Irys on Arweave
All calls work except await bundlr.fund(price);
/Users/Documents/whitelights/bundlr-basics/node_modules/arweave/node/lib/api.js:43
const headers = new Headers(init?.headers || {});
When using this code:
const provider = new ethers.providers.Web3Provider(window.ethereum)
const bundlr = new WebBundlr(
"https://devnet.bundlr.network",
"boba",
provider,
{ providerUrl: "https://rinkeby.boba.network" },
)
await bundlr.ready()
const price = await bundlr.getPrice(file.size)
await bundlr.fund(price)
MetaMask will request you to send testnet ETH to an address. This transaction will confirm and deplete ETH from your account, however, one of two errors will normally cause the code to fail at bundlr.fund
.
One error is "Tx 0x2a994320700ca1597f8d838fac282017094832b900d214cc085c66ca2f2cd497 didn't finalize after 30 seconds".
The other error is "HTTP Error: Posting transaction 0x7b1d1f6bc857cae8d82563ff1749fa1dcb2bdf4e75befd78893164624c7bb2df information to the bundler: 400 Invalid tx"
If you check here or here you will see the transactions actually did go through.
Attempting to create a Bundlr transaction will always result in an error saying there are not enough funds, even though funds are being removed from the user's account. So this seems to be an issue with the devnet RPC. Perhaps it's checking transactions from the wrong RPC or block explorer?
Hi I am trying to use WebBundlr but it gives me below error:
bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)
(node:50) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. 03:39:25
(Use node --trace-deprecation ...
to show where the warning was created)
spec:
Linux
v16.15.1
3.1.2
2.1.1
[email protected]
vite
app
, components
, modules
, build
, vite
@nuxtjs/[email protected]
-
I sent some amount of BNB here a transaction
And got zero balance check here
The following code opens a Metamask window requesting to sign a transaction.
const bundlr = new WebBundlr(bundlrNode, currency, provider, {})
await bundlr.utils.getBundlerAddress(currency)
await bundlr.ready()
Is there a way to check if the signed transaction is already submitted to the bundler node?
For example:
const bundlr = new WebBundlr(bundlrNode, currency, provider, {})
await bundlr.utils.getBundlerAddress(currency)
if (alreadySubmitted) { // any way to do this?
await bundlr.ready()
}
PS: The goal is to avoid showing the Metamask modal for every new upload.
import { providers } from "ethers";
import { WebBundlr } from "@bundlr-network/client";
const provider = new providers.Web3Provider(window.aptos)
const bundlr = new WebBundlr(
"https://node2.bundlr.network",
"aptos",
provider
);
await bundlr.ready();
This is my code. Ethers does not support aptos. Throws following errors:
What to use instead of ethers?
Due to the utilization of the Node.js Crypto module by the package, I am unable to use Bundlr JS SDK in combination with Cloudflare Workers. I would like to inquire whether there are any plans to support this integration in the future. Thank you for your attention to this matter :)
I was trying to look for how to edit a typo on this page : https://docs.bundlr.network/docs/overview
Then tried the Edit this page on the bottom and the link mentioned in the subject was triggered which led to a "Not Found" landing.
The default indexer and api service provider is currently not providing the service anymore,
the best that i found for free and open is https://algonode.io/api/#documentation
but currently the code implemented in the AlgorandCurrency adds node. extension that doesn't work correctly with the different standard of algonode.
I think that a new standard should be adopted to make the old app based on algorand fully functional
When trying to deploy to a Cloudflare worker, I get the error:
Uncaught ReferenceError: window is not defined
at index.js:16761:5 in ../../node_modules/arweave/web/index.js
at index.js:18:51 in __require2
at index.js:16809:38 in ../../node_modules/arbundles/src/deepHash.js
at index.js:18:51 in __require2
at index.js:16909:22 in ../../node_modules/arbundles/src/ar-data-base.js
at index.js:18:51 in __require2
at index.js:87941:26 in ../../node_modules/arbundles/src/ar-data-bundle.js
at index.js:18:51 in __require2
at index.js:88456:28 in ../../node_modules/arbundles/src/index.js
at index.js:18:51 in __require2
[code: 10021]
This is using the Bundlr
(default) client, but looks like the arbundles
dependency is still using some web-based build and causing an issue.
Is there any guidance on how much buffer we should allow when applying funding before sending transactions? In particular, the following does not seem sufficient:
const bytes = bundlrTransactions.reduce((c, d) => c + d.data.length, 0);
const cost = await bundlr.utils.getPrice('solana', bytes);
await bundlr.fund(cost.toNumber());
for (const tx of bundlrTransactions) {
await tx.upload();
}
The upload will fail with Not enough funds to send data
in @bundlr-network/client/build/src/upload.js:221:23
and no other diagnostics
In my particular test, the number of bytes was small (<50kb) and multiplying the cost (<1e-5 SOL) by 2 was sufficient but it would be great to have specifics. Thanks!
The error message shows Wallet.publicKet
not Wallet.publicKey
.
Is this done for purpose or a little spelling mistake?
@bundlr-network/client
: 0.11.2wagmi
: 1.0.8viem
: 0.3.37The WebBundlr docs recommend using the useProvider
and useSigner
hooks from the wagmi
library. These hooks have been deprecated for usePublicClient
and useWalletClient
.
When initializing with viem
as recommended here:
const client: any = createWalletClient({
chain,
transport: custom((window as any).ethereum),
});
client.getSigner = () => client;
client.getAddress = async () => client.getAddresses();
// initialize bundlr instance
const bundlr = new WebBundlr('https://node1.bundlr.network', 'matic', client);
await bundlr.ready();
The bundlr.ready()
no longer opens the injected signer (my MetaMask extension, for instance) to sign for bundlr, and when I call to create the transaction with my bundlr instance:
const fileData = await fileToDataUrl(uploadData.file);
const tx = ctx.bundlr.createTransaction(fileData);
// sign and upload the tx
await tx.sign();
const result = await tx.uploadWithReceipt();
It throws an error:
Error: Owner must be 42 bytes, but was incorrectly 1 at Module.createData
Example of creating transaction
const transaction = await bundlr.createTransaction(JSON.stringify({
id: 'test',
}, {
tags: [
{ name: 'App-Name', value: 'TestAnton' },
],
}));
await transaction.sign();
await transaction.upload();
console.log(transaction.id);
Query GraphQL
query {
transactions(first: 50,
tags: [
{
name: "App-Name",
values: ["TestAnton"]
}
]
) {
edges {
node {
id
}
}
}
}
Example txid: 8igzR2DFLyveeZ-8aps5srfE4jAXtUvf2en5Z-xlSiM
I have a nodejs server setup to upgrade the metadata of NFTs using the @metaplex-foundation/js module. recently i have been getting a lot of TransactionExpiredBlockheightExceededError
on the server logs. after doing some digging in, it was clear that the error occurs only in the Bundlr fund transactions as seen below:
I get TypeError: Bundlr is not a constructor when I call new on Bundlr from my imports.
I am using version "^0.7.16".
I'm using 0.7.15 and WebBundlr.
We can bundlr.fund
on Mac environment with devnet and mainnet.
But we can't bundlr.fund
on Windows environment with devnet. (Windows with mainnet works.)
It returns 400 error for our POST without creating any data on chain so the hash doesn't exist on Solana Explorer.
The error causes after 30 seconds for approve and message is below.
Unhandled Runtime Error
Error: HTTP Error: Posting transaction 535yVew4TKykmX2nfE7vYTx1PLrEjdvC3CoNPhXWCNkuLqRagUob65Kk8awotTKKemuMGMsrBF6piVRJoDQoVzLM information to the bundler: 400 Invalid tx
Call Stack
Utils.checkAndThrow
node_modules/@bundlr-network/client/build/common/utils.js (25:0)
Fund.fund
node_modules/@bundlr-network/client/build/common/fund.js (49:0)
Something is different in between the mac environment and windows one?
We use this in here.
solana-labs/governance-ui#866
The test deploy is here
https://governance-mnv1z1cl1-blockworks-foundation.vercel.app/dao/7y21NhHr64F2VLiLnZakna7B6vmWTEp5CK2GH6ArmVGP/params?cluster=devnet
We use WebBundlr on Create metadata
on that page.
You can also test it after making your own DAO on devnet there.
npx bundlr fund -h https://node1.bundlr.network -c matic -w $PRIVATE_KEY 500000000000000000
produces
assuming raw key instead of keyfile path
Loaded address: 0x....
? Confirmation: send 500000000000000000 wei (0.5 matic) to node1.bundlr.network (0x....)?
Y / N y
0xed66902deab4....
(node:74180) UnhandledPromiseRejectionWarning: Error: HTTP Error: Posting transaction information to the bundler: 400 "Invalid tx"
at Function.checkAndThrow (.../contracts/node_modules/@bundlr-network/client/build/src/utils.js:20:19)
at Fund.<anonymous> (.../contracts/node_modules/@bundlr-network/client/build/src/fund.js:29:29)
at Generator.next (<anonymous>)
at fulfilled (.../contracts/node_modules/@bundlr-network/client/node_modules/tslib/tslib.js:114:62)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:74180) UnhandledPromiseRejectionWarning: Unhandled promise rejection...
using "version": "0.3.0"
The js-sha256
module isn't necessary in current (last 10 years) browsers and causes warnings:
Use of eval in "node_modules/js-sha256/src/sha256.js" is strongly discouraged as it poses security risks and may cause issues with minification.
All current browsers provide SHA256 natively. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
const getSHA256Hash = async (input) => {
const textAsBuffer = new TextEncoder().encode(input);
const hashBuffer = await window.crypto.subtle.digest("SHA-256", textAsBuffer);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hash = hashArray
.map((item) => item.toString(16).padStart(2, "0"))
.join("");
return hash;
};
I'm working on a YouTube type of application and having an issue uploading larger videos.
Smaller videos work great, but I am having issues with videos in the range of 100MB or more.
Here is the error message I'm getting:
Here is the code (next.js app):
// initializing bundlr in pages/_app.js
async function initialiseBundlr() {
await window.ethereum.enable()
const provider = new providers.Web3Provider(window.ethereum);
await provider._ready()
const bundlr = new WebBundlr("https://node1.bundlr.network", "matic", provider)
await bundlr.ready()
setBundlrInstance(bundlr)
bundlrRef.current = bundlr
fetchBalance()
}
// main code in pages/index.js
import BigNumber from 'bignumber.js'
import { useContext, useState } from 'react'
import { MainContext } from '../context'
export default function Home() {
const [file, setFile] = useState()
const [image, setImage] = useState()
const [URI, setURI] = useState()
const [amount, setAmount] = useState()
const { bundlrInstance, initialiseBundlr, balance, fetchBalance } = useContext(MainContext)
async function initialize() {
initialiseBundlr()
}
function onFileChange(e) {
const file = e.target.files[0]
if (file) {
const image = URL.createObjectURL(file)
setImage(image)
let reader = new FileReader()
reader.onload = function () {
if (reader.result) {
setFile(Buffer.from(reader.result))
console.log('file set...')
}
}
reader.readAsArrayBuffer(file)
}
}
async function uploadFile() {
const tags = [{ name: 'Content-Type', value: 'video/mp4' }];
bundlrInstance.useChunking = true
let tx = await bundlrInstance.uploader.upload(file, tags)
console.log('tx: ', tx)
setURI(`http://arweave.net/${tx.data.id}`)
}
async function fundWallet() {
if (!amount) return
const amountParsed = parseInput(amount)
let response = await bundlrInstance.fund(amountParsed)
console.log('Wallet funded: ', response)
fetchBalance()
}
function parseInput (input) {
const conv = new BigNumber(input).multipliedBy(bundlrInstance.currencyConfig.base[1])
if (conv.isLessThan(1)) {
console.log('error: value too small')
return
} else {
return conv
}
}
return (
<div style={containerStyle}>
{
!balance && <button onClick={initialize}>Initialize</button>
}
{
balance && (
<div>
<h3>Balance: {balance}</h3>
<div style={{ padding: '20px 0px'}}>
<input onChange={e => setAmount(e.target.value)} />
<button onClick={fundWallet}>Fund Wallet</button>
</div>
<input
type="file"
onChange={onFileChange}
/>
<button onClick={uploadFile}>Upload File</button>
{
image && (
<video width="320" height="240" controls>
<source src={image} type="video/mp4"/>
</video>
)
}
{
URI && <a href={URI}>{URI}</a>
}
</div>
)
}
</div>
)
}
const containerStyle = {
padding: '100px 20px'
}
I want to try Bundlr in testnet, but the balance is always equal to 0, even though I have added some test eth from faucets
const bundlerHttpAddress = 'https://devnet.bundlr.network'
const currency = 'ethereum'
const privateKey =
'my-private-key'
const bundlr = new Bundlr(bundlerHttpAddress, currency, privateKey, {
providerUrl: 'https://rinkeby.infura.io/v3/',
contractAddress: '0x11D634457F99595aBE7B582739fd52b7ed48995A', // https://rinkeby.etherscan.io/address/0x11D634457F99595aBE7B582739fd52b7ed48995A
})
const address = await bundlr.address
const converted = bundlr.utils.unitConverter(balance)
converted === 0
Trying to fund the wallet with GoerliETH gives these errors:
I use this to initialize bundlr
const initialiseBundlr = async () => {
const provider = new providers.Web3Provider(window.ethereum as any);
await provider._ready();
const bundlr = new WebBundlr(
"https://devnet.bundlr.network",
"ethereum",
provider,
{
providerUrl:
process.env.ALCHEMY_RPC_URL,
}
);
await bundlr.ready();
setBundlrInstance(bundlr);
}
It also gives the warning
"Tx 0xecd7dd59d82f5b591c54cd859fd8847c80cabea38ae3222fcaa8fb952b472224 didn't finalize after 30 seconds"
The same procedure worked for matic but somehow not for ethereum.
Hi
I have a really strange issue whereby the getLoadedBalance method returns a completely wrong amount compared to what I actually have in my wallet and what is shown in the error message when attempting to fund the transfer.
I've checked the providerUrl and wallet address values are the same so not sure what else it could be.
$ solana balance
0.006704023 SOL
const bundlr = new Bundlr(
'https://devnet.bundlr.network',
'solana',
key,
{
timeout: 60000,
providerUrl: 'https://api.devnet.solana.com',
},
);
const balance = await bundlr.getLoadedBalance();
console.log(balance.toNumber() / LAMPORTS);
// returns 4.477788768
const tx = bundlr.createTransaction(data, opts)
const size = tx.size
const cost = await bundlr.getPrice(size);
console.log(cost.toNumber() / LAMPORTS);
// returns 0.00000136
await bundlr.fund(cost.minus(balance));
// returns {"error":{"logs":["Program 11111111111111111111111111111111 invoke [1]","Transfer: insufficient lamports 6699023, need 4477787408","Program 11111111111111111111111111111111 failed: custom program error: 0x1"]}
In the example of lazy funding, balance check is wrong
// If you don't have enough balance for the upload
if (balance.isGreaterThan(price)) {
...
}
it should be balance.isLessThan
// If you don't have enough balance for the upload
if (balance.isLessThan(price)) {
...
}
when I update to v0.10.3, I got cors error on Solana devnet. v0.9 works well
I'm creating a transaction on my own, because I'm implementing a minting process within the same transaction of sendings the funds for the upload, so I guarantee that the funds are sent at the same time the NFT gets minted.
I'm following everything that happens on the funding function for Solana:
And I'm adding an extra SOL transfer from the user that is minting the NFT, so I get the funds from them.
const price = await bundlr.getPrice(totalBytes);
const bundlrAddress = await bundlr.utils.getBundlerAddress("solana");
const minterPayment = SystemProgram.transfer({
fromPubkey: toPublicKey(minterAddress),
toPubkey: toPublicKey(arweaveWallet),
lamports: price.toNumber(),
})
const fundingBundlr = SystemProgram.transfer({
fromPubkey: toPublicKey(arweaveWallet),
toPubkey: toPublicKey(bundlrAddress),
lamports: price.toNumber(),
})
So, minterAddress is sending price
amount to arweaveWallet, and then arweaveWallet (which is the my main wallet for funding the Bundlr node) is sending the same price
amount to bundlrAddress.
You can see full transaction here: https://solscan.io/tx/5DCmfoPmTsbWg6vULD4mrPrZgVekjxQDH1y5WzJTP3dE9rH6um4GDv1uqDwSbLpxH5Tz67DhgZsq9dWKbvFJW54w?cluster=devnet
Here is the part where arweaveWallet is sending price
amount to bundlrAddress. All happening in devnet
But when I query my balance, I'm getting 0 balance.
You can query it here: https://devnet.bundlr.network/account/balance/solana?address=EZgy1WTF1Do4QqpuUvj2NWvHuT5tyLiKqHv7PAvKB8os
Is there something wrong with the devnet? or am I missing something for funding it correctly.
Hi there
There is an issue when using bundlr.upload to upload metadata
let response = await bundlr.upload(JSON.stringify(metadata, null, 2)); let tokenURI = "https://arweave.net/" + response.id; console.log(
Metadata uploaded ==> ${tokenURI});
cat file
{ "name": "name #1", "description": "Description metadata", "image": "https://arweave.net/t0i_Cg4lFTz7_AsIRAiqOEQJJe80KwW26J3-07dsSKE" }%
When viewing the file with cat, there are garbage values at the end. However, it is fine when uploading the file.
Is it possible to upload files for Solana devnet with this package?
Running into the error Error: SubtleCrypto not available!
when trying to load Bundlr in the browser via:
const bundlr = new WebBundlr(
"https://devnet.bundlr.network",
"matic",
provider
);
Stack trace:
Uncaught at new WebCryptoDriver (file:///Users/user/projects/project/node_modules/arweave/web/lib/crypto/webcrypto-driver.js:10:19)
at Object.<anonymous> (file:///Users/user/projects/project/node_modules/arweave/web/common.js:120:18)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Module.require (node:internal/modules/cjs/loader:1057:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (file:///Users/user/projects/project/node_modules/arweave/web/index.js:17:18)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
Maybe looks like there's an underlying dependency issue with arweave
, but I'm not sure how to resolve this. I took a look at this issue but it's unclear what my next step should be other than to mess around with different versions.
Any suggestions on how to proceed?
Using WebBundlr with Vite creates error.
import { WebBundlr } from "@bundlr-network/client";
In util.js:109
file that uses process:
if (process.env.NODE_DEBUG) {
Dependencies:
"@bundlr-network/client": "^0.10.5",
"vite": "^4.2.0",
You can surpass some errors like this with vite.config.ts
export default defineConfig({
plugins: [preact(), tsconfigPaths()],
define: {
'process.env': {}
}
})
But still new errors arises like Buffer object etc.
I've just upgraded from Bundlr -> Irys and I'm getting the following error:
frontend:build: ../../node_modules/@irys/sdk/build/esm/web/irys.js + 52 modules
frontend:build: Cannot get final name for export 'concatBuffers' of ../../node_modules/@irys/sdk/node_modules/arbundles/build/web/esm/src/webUtils.js
starcoin: https://starcoin.org/en/. starcoin has the low gas fee, and should be very nice work with arweave.
Error: node_modules/@irys/query/build/cjs/types.d.ts:50:58 - error TS1005: '?' expected.
[K in keyof T]?: T[K] extends (infer U extends object)[] ? Field : T[K] extends object ? Field<T[K]> : boolean;
"typescript": "~4.6.4"
How do you fund the account on devnet? We are trying using the CLI and a SOL devnet keypair and are getting the below error
Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.
Error whilst funding: failed to send transaction: Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.
I have been playing around with the source code of your JS demo. But having to fill so many inputs and click on so many buttons makes for a terrible user experience on real websites. I have seen that transactions are supported so I was wondering if it would be possible to join all the steps on a single Solana transaction?
For instance, if I try to:
# Example of what I am trying to achieve (this code doesn't work)
const walletAdapter = new PhantomWalletAdapter();
await walletAdapter.connect();
const webBundlr = new WebBundlr("https://devnet.bundlr.network", "solana", walletAdapter, {providerUrl: "https://api.devnet.solana.com"});
const tags = [{name: "Content-Type", value: "image/png"}];
const transaction = bundlr.createTransaction(SOME_FILE_DATA, { tags: tags })
transaction.add(bundler.fund(SOME_AMOUNT))
transaction.add(INTRUCTION_TO_OTHER_SOLANA_PROGRAM_USING_THE_IMAGE_HASH)
await transaction.sign()
const id = (await transaction.upload()).data.id
These are my doubts:
SOME_FILE_DATA
using WebBundlr? because your example doesn't work on web browsers:
const data = fs.readFileSync("data.txt");
INTRUCTION_TO_OTHER_SOLANA_PROGRAM_USING_THE_IMAGE_HASH
)This line removes the first character of my arweave address when retrieving balance. Why does it do this? It breaks the ability to get balance. Removing this line fixes balance retrieval.
You should probably remove this line, or at least detect the character you're trying to remove and only remove it if it's present.
Hi got some problem with transactions on devnet
but the transactions are not reaching the blockchain at all today https://explorer.solana.com/tx/63nrDtYiERVAe78eF1XALQNRqXriQRCsnCvtouEEciuzhNpob314cwcjQxfFVVjqa8Z1QYSPbj6Wg6HaYtMWJACM?cluster=devnet
Other txes are reaching the blockchain but anything from lib is not going thru today
Hi, so I've been trying out the bundlr JS client, specifically the WebBundlr
client, and I'm experiencing issues having the data mined to the network.
I've also noticed that there are a couple of different ways you all have referenced sending a transaction. For example, in the demo application you use this syntax:
await bundler?.uploader.upload(img, [{ name: "Content-Type", value: "image/png" }])
But in the documentation I see this:
const transaction = bundlr.createTransaction(data, { tags });
await transaction.sign();
await transaction.upload();
As for me, I've tried both, and am not sure if there is also maybe something I'm doing wrong in my code. Here's a look at essentially what I'm doing:
async function connect() {
await window.ethereum.request({ method: 'eth_requestAccounts' })
const provider = new providers.Web3Provider(window.ethereum);
await provider._ready()
const bundlr = new WebBundlr("https://node1.bundlr.network", "matic", provider)
await bundlr.ready()
setBundlrInstance(bundlr)
}
/* create a transaction (plain text, JSON, file, image, video, etc..) */
async function createTransaction() {
const data = "hello world"
const tags = [
{ name: 'App-Name', value: 'PublicSquare' },
{ name: 'Content-Type', value: 'text/plain' },
{ name: 'Version', value: '1.0.1' },
{ name: 'Type', value: 'post' }
]
const transaction = bundlrInstance.createTransaction(data, { tags })
await transaction.sign()
await transaction.upload()
console.log('transaction id: ', transaction.id)
}
The data seems to be saving to the network, but after a while it is dropped.
I have had one or two transactions mined, but I've been doing so much experimentation I'm not sure why those worked but my others did not.
Is there anything that I should know that might help me understand better how this works?
Thanks for your time.
This command
irys upload metadata.json -h https://node1.irys.xyz -t solana -w <my private key>
gives an error
Loaded address: <my address>
Error whilst uploading file: Not enough balance for transaction
even though my address has ~10 usd on balance
solana balance
0.09908193 SOL
Steps to Reproduce:
npm install @irys/sdk
npm audit
# npm audit report
axios 0.8.1 - 1.5.1
Severity: moderate
Axios Cross-Site Request Forgery Vulnerability - https://github.com/advisories/GHSA-wf5p-g6vw-rhxx
No fix available
node_modules/aptos/node_modules/axios
aptos <=1.13.3
Depends on vulnerable versions of axios
node_modules/aptos
@irys/sdk *
Depends on vulnerable versions of aptos
node_modules/@irys/sdk
I am trying to get the estimated price for uploading 1000 bytes to bundlr, using -c currency "solana", on -h host https://node1.bundlr.network:
bundlr price 1000 -c solana -h https://node1.bundlr.network
I get this error when I run this command:
Error whilst getting price: Error initialising Bundlr client - The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
Why am I not able to get the price with this tool? It is mentioned here and here in the docs:
https://docs.bundlr.network/docs/client/cli#check-the-price-of-a-bundlr-node
https://docs.bundlr.network/docs/hidden/client/upload-with-solana#fund-a-bundler-with-sol
Aptos released a new TS SDK and it is recommended to migrate over to it for its benefits and support and also because the legacy one is not currently developed and/or maintained anymore.
I can clone and look at the irys Aptos implementation and start the migration but wondering if there is anything we should keep in mind while doing it? are there any side effects for a complete migration? should we keep both implementation for a grace period?
Appreciate your help!
Hi runned into issue with uploading imgs im using solana + WebBundlr and randomly getting not enough funds error when trying to upload img. i also tried different functions to get img byte size and getting same results for example Buffer.byteLength(buff). when i add something like 500 bytes "margin" for all imgs it works all the time.
is this some problem with price fcn or im missing something in my code? thanks
code:
export const uploadImage = async (
imageFile: Buffer,
cluster: string,
rpcEndpoint: string,
wallet: SignerWalletAdapter
) => {
const bundlr = await initBundlr(cluster, rpcEndpoint, wallet);
if (!bundlr) return;
if (imageFile == null) return;
const loadedBalance = await bundlr.getLoadedBalance();
const balance = bundlr.utils.unitConverter(loadedBalance.toNumber());
const balanceNum = balance.toNumber();
const price = await bundlr.utils.getPrice("solana", imageFile.length);
const amount = bundlr.utils.unitConverter(price);
const amountNum = amount.toNumber();
if (balanceNum < amountNum) {
await bundlr.fund(Math.ceil((amountNum - balanceNum) * LAMPORTS_PER_SOL));
}
const imageResult = await bundlr.uploader.upload(imageFile, {
tags: [{ name: "Content-Type", value: "image/png" }],
});
const arweaveImageUrl = `https://arweave.net/${imageResult.data.id}?ext=png`;
return arweaveImageUrl;
};
The Solana network is quite congested at the moment. Transaction priority fees don't seem to be wired in for payments in SOL.
There seems to be a to-do in
js-sdk/src/web/tokens/solana.ts
Line 106 in 9d9f626
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.