Error building when using a normal third sdk

For Workes & Pages, what is the name of the domain?

local domain

What is the error message?

Build failed with 9 errors: Could not resolve “crypto”, “stream”, “http”, “https”, “zlib”

What is the issue or error you’re encountering

Unable to build Cloudflare Worker due to unresolved Node.js built-in modules

What steps have you taken to resolve the issue?

Added Node.js compatibility flag in wrangler.toml
Modified webpack.config.js to add polyfills and fallbacks for Node.js modules
Installed necessary dependencies including crypto-browserify, stream-browserify, etc.
Updated tsconfig.json for Cloudflare Workers environment

What are the steps to reproduce the issue?

  1. GitHub - unisat-wallet/wallet-sdk install this sdk and axios, like this “@unisat/wallet-sdk”: “^1.4.0”,“axios”: “^1.7.7”,
  2. Copy mempool-api and open-api to src, from dev-support/wallet-sdk-examples/example at master · unisat-wallet/dev-support · GitHub
  3. Write sample code to use unisat-wallet sdk, like this:
    import { AddressType } from “@unisat/wallet-sdk”;
    import { NetworkType } from “@unisat/wallet-sdk/lib/network”;
    import { sendBTC } from “@unisat/wallet-sdk/lib/tx-helpers”;
    import { LocalWallet } from “@unisat/wallet-sdk/lib/wallet”;
    import { MempoolApi } from “./mempool-api”;
    import { OpenApi } from “./open-api”;

export default {
async fetch(request, env, ctx): Promise {
var mempoolApi = new MempoolApi({
baseUrl: “mempool - Bitcoin Explorer”,
});
var openApi = new OpenApi({
baseUrl: ‘https://open-api-fractal-testnet.unisat.io’,
apiKey: ‘fffff’,
});

	var wallet = new LocalWallet(
        'ffffff',
        AddressType.P2PKH,
        NetworkType.TESTNET
    );


	return new Response('Hello World!');
},

} satisfies ExportedHandler;

1 Like