How to transfer your MakerDAO Vault via code?

Steps to transfer vault:

  1. Go to https://dsa.instadapp.io/makerdao.

  2. Open chrome console.

    Press Command+Option+I (Mac) or Control+Shift+I (Windows)

  3. Paste your code in the Chrome console. (You can find the code below to paste)

  4. Change vaultID to the vault number you want to transfer.

  5. Change nextOwner to the address you want to transfer your vault. (Becarfull

  6. Click enter to execute your code.

Note:

nextOwner variable address in the below code should be changed carefully. If you change it to the wrong address you will end put losing your vault forever. And this can’t be undone

Code Snippet:

let spells = dsa.Spell();

let vaultID = "123"; // NOTE: change to your Vault ID you want to transfer

// Note: `nextOwner` variable address should be changed carefully. 
// If you change it to the wrong address you will end put losing your vault forever. And this can't be undone
let nextOwner = "0x....0000"; //  NOTE: change to the address you want to transfer your vault from Instadapp.

spells.add({
    connector: "auth",
    method: "add",
    args: [nextOwner]
});

spells.add({
    connector: "maker_old",
    method: "transfer",
    args: [vaultID, nextOwner]
});

spells.add({
    connector: "auth",
    method: "remove",
    args: [nextOwner]
});

await dsa.cast(spells).then(console.log); // If transaction is sent to blockchain, it will return tx hash.

Doesn’t need add and remove auth if the nextOwner is already in the auth list.

@BlackSwan If the nextOwner is already an auth, then no need of add and remove spell from the above example.