title: How to sign token transaction in Serum Anchor
body: <p>I have a simple contract using Serum Anchor (on Solana) that transfers tokens from one party to another. It is currently failing with:</p>
  <p><code>Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Cross-program invocation with unauthorized signer or writable account</code></p>
  <p>Full code from snippets below at: <a href="https://gist.github.com/h4rkl/700400f515ab0736fd6d9318d44b2dca" rel="noreferrer">https://gist.github.com/h4rkl/700400f515ab0736fd6d9318d44b2dca</a></p>
  <p>I'm setting up 4 accounts for the transaction:</p>
  <pre class="lang-js prettyprint-override"><code>  let mint = null; // key for token mint
    let god = null; // main program account to pay from and sign
    let creatorAcc = anchor.web3.Keypair.generate(); // account to pay to
    let creatorTokenAcc = null; // token account for payment
  </code></pre>
  <p>I'm setting them up as follows:</p>
  <pre class="lang-js prettyprint-override"><code>const [_mint, _god] = await serumCmn.createMintAndVault(
        program.provider,
        new anchor.BN(MINT_TOKENS),
        undefined,
        MINT_DECIMALS
      );
      mint = _mint;
      god = _god;
  
      creatorTokenAcc =await serumCmn.createTokenAccount(
        program.provider,
        mint,
        creatorAcc.publicKey
      );
  </code></pre>
  <p>And then I make the payment with the following method:</p>
  <pre class="lang-js prettyprint-override"><code>const INTERACTION_FEE = 200000000000000;
  await program.rpc.interaction(new anchor.BN(INTERACTION_FEE), {
        accounts: {
          from: god,
          to: creatorTokenAcc,
          owner: program.provider.wallet.publicKey,
          tokenProgram: TOKEN_PROGRAM_ID,
        },
      });
  </code></pre>
  <p>In the contract that the method is triggering my interaction process is as follows:</p>
  <pre class="lang-rust prettyprint-override"><code>pub fn interaction(ctx: Context&lt;Interaction&gt;, interaction_fee: u64) -&gt; ProgramResult {
          let cpi_accounts = Transfer {
              from: ctx.accounts.from.to_account_info().clone(),
              to: ctx.accounts.to.to_account_info().clone(),
              authority: ctx.accounts.owner.clone(),
          };
          let cpi_program = ctx.accounts.token_program.clone();
          let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts);
          token::transfer(cpi_ctx, interaction_fee)?;
         
          Ok(())
      }
  </code></pre>
  <p>I have setup the Interaction <code>pub struct</code> with the following params:</p>
  <pre class="lang-rust prettyprint-override"><code>#[derive(Accounts)]
  pub struct Interaction&lt;'info&gt; {
      #[account(mut, has_one = owner)]
      from: CpiAccount&lt;'info, TokenAccount&gt;,
      #[account(&quot;from.mint == to.mint&quot;)]
      to: CpiAccount&lt;'info, TokenAccount&gt;,
      #[account(signer)]
      owner: AccountInfo&lt;'info&gt;,
      token_program: AccountInfo&lt;'info&gt;,
  }
  </code></pre>
  <p>As far as I can tell the params are correct, and the <code>god</code> account owns the wallet as the payer and is the signer. Why is this failing, and what am I missing? I'm completely out of ideas.</p>