Channel Creation depositAndCreate Transaction Fails with Signature Validation #41
-
|
After receiving The I'm submitting tx through apps.yellow.com and reject the tx to see the logs below: Then here's my app's log: My Implementation1. Signing create_channel RPC Request// Using @erc7824/nitrolite SDK
const sessionSigner = createECDSAMessageSigner(sessionKey.privateKey);
const createRequest = {
chain_id: 8453,
token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
amount: '10000',
session_key: sessionKey.address,
participant: account
};
const message = {
req: [requestId, "create_channel", createRequest, timestamp],
sig: []
};
// Sign the RPC request
const signature = await sessionSigner(message.req);
message.sig = [signature];
// Store this signature for depositAndCreate
setUserSignature(signature);2. Using Signatures in depositAndCreateconst stateStruct = {
intent: state.intent,
version: BigInt(state.version),
data: (state.state_data || '0x') as `0x${string}`,
allocations: state.allocations.map(alloc => ({
destination: alloc.destination,
token: alloc.token,
amount: BigInt(alloc.amount)
})),
sigs: [
userSignature, // Signature from create_channel RPC request
response.server_signature // Broker signature from create_channel response
]
};
await walletClient.writeContract({
address: '0x490fb189DdE3a01B00be9BA5F41e3447FbC838b6',
abi: custodyAbi,
functionName: 'depositAndCreate',
args: [
'0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC
10000,
channelStruct,
stateStruct
],
account: userAddress
});Question: Should |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hello, @bertankofon !
The |
Beta Was this translation helpful? Give feedback.
-
|
Solved! Thanks alot :) @nksazonov |
Beta Was this translation helpful? Give feedback.
Hello, @bertankofon !
Thanks for using Yellow SDK!
The
state.sigs[0]should be the user signature of the channel state struct (without signatures, obviously).Please note that it is more convenient to use Yellow SDK NitroliteClient's
depositAndCreatemethod, that basically takes the response fromcreate_channelClearnode's endpoint as a parameter, performs all the necessary transformations and even submits the transation!